How to iterate over a list of combox values ​​and select one of them

How do I iterate over a list of ComboBox values ​​so that I can check each value and select one of them efficiently?

Examples in a C # or VB.Net greeting.

+6
source share
2 answers

To iterate over combobox values, you can use the Items property. If the combobox values ​​are strings, the VB code will look like this:

For each item As String in myComboBox.Items 'Do something Next 

To select a value, you can use the SelectedItem property:

 myComboBox.SelectedItem = "SomeValueInComboBox" 
+10
source
 foreach (var item in comboBox1.Items) Console.WriteLine(item.ToString()); 
+1
source

Source: https://habr.com/ru/post/911573/


All Articles