views:

38

answers:

2

Hi all.

I have a ComboBox control of DropDown type which contains items "Vx", "V", "G", "g".

Edit field text is "V" ( :)

The problem is: when I open dropdown list, item "Vx" highlighted as selected, not "V". So I assume combobox uses FindString to find SelectedItem - so search result is equivalent to first matched item by case-insensitive string.StartsWith.

The question is: how I can override this behaviour to find full-matched item? I need case-sensitive search with full equivalent of strings, not only StartsWith. For entered "V" i need item "V" (not "Vx") to be selected when combobox dropdown list is opening.

Thank you for replies.

A: 

You can disable sort elements property in your combobox and add items in your arrange what you want.

Svisstack
Hm. May be it is some missunderstanding.Problem is not is sorting of elements. Problem is in search - when combobox tries to display selected item when dropdown list is opening, it gets the text entered in edit field, finds a first item matched by StartsWith and markes it as SelectedItem.But I need override only this 'find' behaviour to use string.Equals instead of string.StartsWith. Of course, alplabetical sorting is workaround - "V" item will be always before "Vx". But I need custom sorting.
albicelestial
ahhh, then you faster write own control inheritanced from ComboBox with your search algorithm implemented.
Svisstack
+1  A: 

Do you need to type in the combo box? If not, change the DropDownStyle to DropDownList.

NascarEd