I have combobox1 and comboox2 and in combobox1 my elements are A,B,C and combobox2 a,b,c,d,e,f...And I added this elements using property screeen(I mean not with code).
combobox1 combobox2
----------------- ----------------
A a
B b
C c
d
e
f
A related a,b,c and B related b,c and C related d,e,f.
When I choose "A" I want to see just a,b,c ; when select "B" just b,c etc.
can I give index number of combobox1's items ? When I choose "A" I want to see just "a","b","c" elements(I mean 0,1,2 indeks numbers) when choose "B" just b,c (I mean 1,2 indeks numbers). I want to do like that cause if there is no indeks numbers I have to make all relationship with writing codes.I wrote a little code below but it is long way.
Index logic is better, sure if there is index logic in combobox :)
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox2.Items.Clear();
switch (comboBox1.SelectedItem.ToString())
{
case "A":
comboBox2.Items.AddRange(new string[] { "a", "b", "c" });
break;
case "B":
comboBox2.Items.AddRange(new string[] { "b", "c" });
break;
}
comboBox2.SelectedIndex = -1;
}