Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.

C#
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?
Posted
Updated 1-Mar-13 0:32am
v3

C#
private void ListTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            DocumentName = ListTemplate.SelectedItem.ToString();
            RefreshForm();
        }
 
Share this answer
 
Try this
C#
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
         this.textBox1.Text = toolStripComboBox1.Text;
}
 
Share this answer
 
v2
Comments
Nomardus 1-Mar-13 6:48am    
Sorry, but this does exactly what I already had, I need to load the original text file into the textbox.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900