Adam azhari

Adam azhari

  • 1.9k
  • 12
  • 176

How to set valueMember for combobox items C#

Jun 6 2020 1:03 PM
I had to find out how to set values into ComboBox items

So i have a combo box with two string items and each item make some changes on other combo box then save to xml

Now i tried to set value for this items but the problem is the xml output shows only 1 value
  1. comReg.DisplayMember = "Item 1";  
  2. comReg.ValueMember = "1";  
  3. comReg.DisplayMember = "Item 2";  
  4. comReg.ValueMember = "2";  
  5. comPer.Items.Clear();  
  6. switch (comReg.SelectedItem.ToString()) {  
  7. case "Item 1":  
  8. comPer.Items.AddRange(new string[]{"1""2""3""4" });  
  9. break;  
  10. case "Item 2":  
  11. comPer.Items.AddRange(new string[]{"1""2""3""4""5""6""7""8""9""10""11""12"});  
  12. break;  

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (1)