C# ComboBox duplicates selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aicho
    New Member
    • Mar 2008
    • 1

    C# ComboBox duplicates selection

    Hi,

    We've recently noticed a very strange occurrence with one of our comboboxes. In that instance, it concerned a databound combobox bound to a collection of items of which some had the same textual value, although there is always an ID to seperate them. They appeared in the combobox as two or more identical strings. However, when selecting the second or following string instead of the first, after the combobox loses focus, it reverts its selected index back to the first of these items, regardless of the fact that they are actually different! It appears to look only to the SelectedText property. This causes the other information dependant on the selected ITEM (not TEXT) to be changed back to the first in the list...

    I have tried the same with non-databound items, just added a list of strings to the ComboBox and the same thing occurred... The ComboBox just can't seem to select a duplicate text if it is in the list.

    Any ideas about this would be appreciated,
    Sincerely,
    Aicho
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    selectedItem is the same as selectedText. You should use selectedValue when you have two items containing the same Text in your combobox. Give this a try and let us know if you have any more questions.

    Nathan

    Comment

    Working...