I wrote a WPF application in which my ComboBox.Items.IndexOf(ItemName);
giving -1 even though Item is present in the ComboBox
items
list. Can anybody please help me to get the solution.
Thanks in advance
I wrote a WPF application in which my ComboBox.Items.IndexOf(ItemName);
giving -1 even though Item is present in the ComboBox
items
list. Can anybody please help me to get the solution.
Thanks in advance
.IndexOf
is looking for the object in the items collection rather than looking for it by name (which is what you are indicating that you want to do). You should use ComboBox.FindStringExact("ItemName")
to get what you require.
I do believe that this is how you set the list to blank, hence the " - " before the 1, indicating that it's below the 0 threshold which items begin to be indexed.