views:

91

answers:

0

I am writing a custom control that has a textbox. Inside the control I have a class that implements the AutoCompleteStringCollection so I can keep a Guid id with each string. This allows me to add autocomplete to a textbox but relate the selected text back to the database through the id. I want to add a property for forcing a selection from the list.

For instance say a list contains pineapple, apple, pear, and banana. If the user types a "p" Windows displays the dropdown Suggest style list sorted with "pear", then "pineapple" irregardless of the order they actually exist in the collection. The expected behavior for this scenario is to tab off the control and the first item in the list should be selected. However when I iterate through the list looking for the first sub-string match I find "pineapple" first. I can sort the data prior to assigning it to the list, but that would be a bad work-around. At this point all the code is contained inside a custom control so I don't want to require others to have to add items to the collection in a sorted order for this function to work. My first choice would be to to sort the actual collection, my second choice would be to copy the collection to a list or array that already has sorting.