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.

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;
           }

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.