I am having the strangest issue using C# and VS 2008 Pro

I have a Windows Forms application with a tab control with two tabs.

        List<string> DataA = new List<string> { "", "A", "B", "C", "D" };
      List<string> DataB = new List<string> { "", "E", "F", "G", "H" };

        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.DataSource = DataA;
            comboBox2.DataSource = DataB;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            comboBox1.Text = "Test1";
            comboBox2.Text = "test2";
        }

Pretty straightforward. 

Now if I put both comboboxes in the first TabPage when I click button1 it
fills in the text even though it is not on the list of it's datasource.
That is fine with me, I want it that way.

Now, if I move either combobox to the second tabpage then its text will not
get populated UNLESS it matches a string from the datasource.

So while Combo1 and Combo2 will both end up with "Test1" and "Test2", if I
move ComboBox2 to the 2nd tabpage then Combo2.Text will not be populated.
If I change the code to say 
        
        comboBox2.Text = "F";

then it will populate.

Anybody have any ideas?

Greg



 




Reply via email to