listBox selected item

后端 未结 3 1796
难免孤独
难免孤独 2021-01-23 05:43

I have three listBoxes:

listBox1 have the following items: Fruit and vegetable.

listBox2 have the following items: Orange, Apple, cucumber and Tomato.

li

3条回答
  •  花落未央
    2021-01-23 06:08

    you can try

    listBox1_SelectedIndexChanged(obj ... , sender e)
    {
         if(listBox1.SelectedItem.ToString() == "Fruit")
         {
            listBox2.Items.Add("Orange");
            listBox2.Items.Add("Apple");
          }
         else if()
         {
            // other conditons
          }
    }
    
    listBox2_SelectedIndexChanged(obj ... , sender e)
    {
         if(listBox2.SelectedItem.ToString() == "Apple")
         {
            listBox3.Items.Add("Red");
            listBox3.Items.Add("Green ");
          ........
          }
         else if()
         {
            // other conditons
          }
    }
    

    read http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.selectedindexchanged.aspx

提交回复
热议问题