I have a custom combobox (
ButtonDropDown using Custom Control (ButtonDropDownMenu Control)[
^])control that I have filled with some filenames from a listarray, but now I would like it if I clicked on a filename that this filename loads into the textbox.
This is the code I got so far.
private void buttonDutch_Click(object sender, EventArgs e)
{
string[] Filelistarray = Directory.GetFiles(@"C:\Users\a961835\Programming", "*.txt");
List<string> fileNames = new List<string>();
foreach (string FileName in Filelistarray)
{
string filenameWithoutPath = Path.GetFileName(FileName);
fileNames.Add(filenameWithoutPath);
}
toolStripComboBox1.Items.AddRange(fileNames.ToArray());
}
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (toolStripComboBox1.SelectedIndex > 0)
{
this.textBox1.Text = toolStripComboBox1.SelectedItem.ToString();
}
}
Anyone who has an idea how to do this?