Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 C# C#4.0 Text
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
Edited 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 at 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
0 Sergey Alexandrovich Kryukov 368
1 Richard MacCutchan 240
2 OriginalGriff 230
3 Jared Sanow 145
4 Vinay Mistry 133
0 Sergey Alexandrovich Kryukov 5,955
1 OriginalGriff 4,805
2 CPallini 2,473
3 Abhinav S 1,507
4 Richard MacCutchan 1,437


Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 7 Mar 2013
Copyright © CodeProject, 1999-2014
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