Combobox Visual Studio Csharp

Asked

Viewed 43 times

1

I’m complementing a system with two combobox

In the comboBox1 the name of the folders shall appear for user selection, In the comboBox2 should appear the .exe which will be transferred to a directory after clicking on a button to copy the selected file in combobox.

I looked in some tutorials on the internet, but I did not find any this way.

Does anyone have any tips??

1 answer

1


How popular the combobox:

private void FillCombo()
{
    var dirs = Directory.GetDirectories(@"C:\temp");
    var files = Directory.GetFiles(@"C:\test2", "*.exe");

    foreach (var t in dirs)
    {
        cmbDir.Items.Add(t);
    }

    foreach (var t in files)
    {
        cmbArq.Items.Add(t);
    }
}

To copy the files:

File.Copy("arquivoOrigem", "arquivoDestino");

Don’t forget the using System.IO;

Now if you want to select more than one file you can use the checkedListBox or Listview. The procedure is the same.

  • I understood the logic, it’s quite simple. But I’m having difficulties in cmb, where returns the error that it does not exist in the current context.

  • You need to renown cmbDir and cmbArq pro name the combobox Voce has in its application

  • 1

    worked my friend thank you very much

Browser other questions tagged

You are not signed in. Login or sign up in order to post.