Hi,
I have a combo editor with AutoSuggest turned on. The issue is that I want to populate the list based on the key they press. (When they hit 'W' i am querying the database and populating a valuelist, that valuelist belongs to the Valuelist of this combo box).
With the Key Down, it works nice because it populates the list, then AutoSuggests.(the list pops up automatically) The Key_Down though is firing twice (and I checked, I only have it registered once).
So I moved it to the ValueChanged, and it works but the AutoSuggest does not. I am guessing because I am repopulating the value list as they type. I want to perform the auto suggest after the query (IE, i want it to auto pop)
hope that makes sense.
I think I have it working better using the Text_Changed Event,..however it does not auto pop the list until the 2nd letter is typed.
if (ucmboCust.Text.Length > 0) queryCustomer(true);else if (ucmboCust.Text.Length == 0) vlCust.ValueListItems.Clear();
Sounds like it's probably a timing issue. I'm not sure at exactly what point the auto-suggest takes place.
But from what you are describing, it probably happens before the TextChanged event is fired. So... when you type the first characters, the list is empty, and there is nothing for AutoSuggest to show. Then TextChanged fires and the list gets populate. Then when you type the second character, the Auto-Suggest is operating on the list that was created from the first character - but you only see the items that match both characters, since the rest are filtered out.
I assume that you are doing all this for efficiency so that you don't have to load the entire list into memory all at once. Is that correct?
If so, then why even populate the list a second time? Why not populate it once based on only the first character? After that, you will already have loaded into memory everything beginning with that character, so it's actually less performant to go out and re-query the data to make the list smaller, isn't it?
Also, if you plan to use ValueMember and DisplayText on your list, then your approach will not work, since you will be removing items from the list that the control needs in order to translate one to the other.