none
Search for Substring in AutoCompleteStringCollection() RRS feed

  • Question

  • I have a problem that I'm trying figure out with AutoComplete.

    I have dynamically created a AutoCompleteStringCollection and have multiple values however I would like this control to be very responsive so I want it to search for a substring in a AutoCompleteStringCollection Item.

    For instance say my collection has the following values

    Apple, Ardvark, Baker, Blue, Bannana

    When I press "a" the auto complete comes up but only list Apple and Ardvark, However there is an "a" in Apple, Ardvark, Baker and Bannana.

    I've been trying to figure out how I can get AutoComplete to search for a substring but I've had no succsess. Any help would be much appriciated.

    Nic

     

     

    Tuesday, February 6, 2007 9:39 PM

Answers

  • Hi, Nic

    The function of the autoComplete in some control have wrapped some windows shell method.

    If you want to override the function, I'm afraid it's possible to create a custom control to implement such a function. But it seems to be somewhat complicated, since you have to familiar with api of the windows.

    Otherwise, to implement it in UI way.(handle the onkeydown event to show sth in another control ). But the performance of it will be low.

    Thank you

    Thursday, February 8, 2007 2:11 AM

All replies

  • Hi,

    Logically, the function you mentioned does not have much relation with autoComplete function.

    AutoComplete tend to help user to complete the string start with the value which have been entered.

    So if you want to realize it, you'd override the the auto-complete function with the specific arithmetic.

    Thank you

    Wednesday, February 7, 2007 7:54 AM
  • That makes sense however while I was searching for a way to do this, I could not figure out where I could override the auto-complete function.

     

    Nic

    Thursday, February 8, 2007 12:56 AM
  • Hi, Nic

    The function of the autoComplete in some control have wrapped some windows shell method.

    If you want to override the function, I'm afraid it's possible to create a custom control to implement such a function. But it seems to be somewhat complicated, since you have to familiar with api of the windows.

    Otherwise, to implement it in UI way.(handle the onkeydown event to show sth in another control ). But the performance of it will be low.

    Thank you

    Thursday, February 8, 2007 2:11 AM
  • hmmm I'm suprised nobody has done this yet. I'll look into the windows API's at a later date but for the time being I will try your suggestion maybe by adding AutoCompleteListCollection to the ComboBox List items and onTextChanged or onKeyPress filter the items in the ComboBox. the only draw back to this is I will also need to handle events for the upKey downKey and tab key so that it responds just like auto-complete.

    I'll post code and performance benchmarks when complete. I'm sure many people are looking for this functionality.

    Nic

    Thursday, February 8, 2007 3:59 PM
  • G'day Nic,

    Did you ever find a solution for this? I'm trying to do the exact same thing. It occurs to me that the AutoComplete must already be able to do this. When it is used to autocomplete URLs it happily ignores chunks of the matching text at the beginning of the matching strings.For example, typing "fo" will match with "http://forums.microsoft.com" or "http://www.forex.com". It's possible (likely???) that these are hard coded to be ignored.

    If you solved this, I'd appreciate the solution.

    Thanks,

    Derek Tomes.
    Wednesday, June 27, 2007 4:17 AM