I have a combobox, and I would like to search through every element in it.
How can I do this? (also the number of items is not the same everytime, but this is not so important).
I am using c# windows form application.
I have a combobox, and I would like to search through every element in it.
How can I do this? (also the number of items is not the same everytime, but this is not so important).
I am using c# windows form application.
you can do this
for (int i = 0; i < myComboBox.Items.Count; i++)
{
string value = myComboBox.GetItemText(myComboBox.Items[i]);
}
GetItemText
not there any more, use getContent()
–
Ragouzis Use a foreach
loop. It will iterate all your items of ComboBox regardless of their count, e.g.
foreach(var item in myComboBox.Items)
{
// do something with your item
}
© 2022 - 2024 — McMap. All rights reserved.