0

I have a one textbox on the form and combo1 in datagridview
when form is load combo1 is empty
if value of text1.text is 'A'
then combo1 should have below items.
combo1.Items.Clear();
combo1.Items.Add("Director");
combo1.Items.Add("MD");
combo1.Items.Add("President");
combo1.Items.Add("Chairman");
combo1.Items.Add("FullTimeDir");
and
if value of text1.text is 'B' then combo1 should have below values.
combo1.Items.Clear();
combo1.Items.Add("Director");

But when i run the form and change the value of textbox

the combo1 remains blank

Note: I have used textbox.validating event. to change combo1 values

so pls help me for this problem
thanks in advance.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Naik Dhiren
0

I have a one textbox on the form and combo1 in datagridview
when form is load combo1 is empty
if value of text1.text is 'A'
then combo1 should have below items.

combo1.Items.Clear();
combo1.Items.Add("Director");
combo1.Items.Add("MD");
combo1.Items.Add("President");
combo1.Items.Add("Chairman");
combo1.Items.Add("FullTimeDir");

and
if value of text1.text is 'B' then combo1 should have below values.

combo1.Items.Clear();
combo1.Items.Add("Director");

But when i run the form and change the value of textbox

the combo1 remains blank

Note: I have used textbox.validating event. to change combo1 values

so pls help me for this problem
thanks in advance.

Try this:

       combo1.Items.Clear();
       if (text1.Text=="A")
           {
            combo1.Items.Add("MD");
            combo1.Items.Add("Director");                
            combo1.Items.Add("President");
            combo1.Items.Add("Chairman");
            combo1.Items.Add("FullTimeDir");
            combo1.SelectedIndex = 0;
           }
       else if (text1.Text == "B")
           {
           combo1.Items.Add("Director");
           combo1.SelectedIndex = 0;
           }

Edited by mike_2000_17: Fixed formatting

0

Dear Seemant,
This solution is not work for combo in datagridview
so pls help me more.
thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.