devilonline
New member
- Joined
- Nov 15, 2020
- Messages
- 3
- Programming Experience
- Beginner
Hi,
I have an combox, that i fill with items.
when i fill it with items I want to clear the items if there is any there. the problem is that the combox doesnt keep the items like shown in the pic
here is the code that i have:
I have an combox, that i fill with items.
when i fill it with items I want to clear the items if there is any there. the problem is that the combox doesnt keep the items like shown in the pic
here is the code that i have:
C#:
if (comboBox1.SelectedIndex == 0)
{
label1.Text = "choice 1";
comboBox2.Items.Clear();
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\\Work\\tip.xml");
XmlNode idNodes = doc.SelectSingleNode("colors/pos3");
foreach (XmlNode node1 in idNodes.ChildNodes)
if (!comboBox2.Items.Contains(node1.InnerText))
{
comboBox2.Items.Add(node1.InnerText);
}
switch (comboBox2.SelectedIndex)
{
case 0:
label2.Text = "choice 21";
XmlDocument doc1 = new XmlDocument();
doc1.Load(@"C:\\Work\\tip.xml");
XmlNode idNodes1 = doc.SelectSingleNode("colors/pos4");
foreach (XmlNode node1 in idNodes1.ChildNodes)
if (!comboBox3.Items.Contains(node1.InnerText))
{
comboBox3.Items.Add(node1.InnerText);
}
break;
case 1:
label2.Text = "choice 22";
XmlDocument doc2a = new XmlDocument();
doc2a.Load(@"C:\\Work\\tip.xml");
XmlNode idNodes2a = doc.SelectSingleNode("colors/pos5");
foreach (XmlNode node1 in idNodes2a.ChildNodes)
if (!comboBox3.Items.Contains(node1.InnerText))
{
comboBox3.Items.Add(node1.InnerText);
}
switch (comboBox3.SelectedIndex)
{
case 0: label3.Text = "choice 31";break;
case 1: label3.Text = "choice 32"; break;
case 2: label3.Text = "choice 33";
button2.Visible = true;
break;
}
break;
Last edited by a moderator: