Reputation: 7170
How do I cycle through a ComboBox Values list so I can check each value and select one of them efficiently?
Examples in C# or VB.Net welcome.
Upvotes: 7
Views: 19290
Reputation: 17845
To cycle through combobox values, you can use the Items property. If combobox values are strings, the VB code would 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"
Upvotes: 11
Reputation: 489
foreach (var item in comboBox1.Items)
Console.WriteLine(item.ToString());
Upvotes: 1