Click here to Skip to main content
12,952,792 members (33,964 online)
Rate this:
 
Please Sign up or sign in to 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.

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 28-Feb-13 0:00am
Updated 1-Mar-13 0:32am
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try this
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
         this.textBox1.Text = toolStripComboBox1.Text;
}
  Permalink  
v2
Comments
Darthillian 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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

private void ListTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            DocumentName = ListTemplate.SelectedItem.ToString();
            RefreshForm();
        }
  Permalink  

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,389
CHill60 3,490
Maciej Los 3,103
Jochen Arndt 1,975
ppolymorphe 1,920


Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 7 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100