I dont exactly know the reason ... but you can do something like this
to take desired effects in your button click handler.


private void button1_Click(object sender, EventArgs e)
        {
            //for combobox on 2nd tab.. this combobox is on second tab
            tabControl1.SelectedIndex = 1;
            comboBox1.Text = "test1";
            //for combobox on 1st tab.. this combobox is on first tab
            tabControl1.SelectedIndex = 0;
            comboBox2.Text = "test2";
        }

On Aug 30, 9:33 pm, "Greg Hile" <[email protected]> wrote:
> 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