TextBox AutoComplete Not working properly

后端 未结 5 531
天涯浪人
天涯浪人 2021-01-20 14:29

I am trying to implement a textbox autocomplete with a custom datasource in the form of an array which shows suggestions on single character input. But when i run the progra

5条回答
  •  逝去的感伤
    2021-01-20 14:47

    AutoComplete suggests after the second char is being pressed is normal because in the first place, you have initialized the arr (which is your custom datasource) into an empty array. You have populated your arr in TextChanged event and that's why AutoComplete works at the second char because your datasource is filtered based on your first char (which is definitely what you don't want).

    Here's a suggestion:

    • On the FormLoad event of your application, fill arr with all the possible suggestions (I think the source of suggestion is from database right?). This will allow textbox to suggest on your first char.

    • When you have entered the first char, on the TextChanged event reload your arr datasource based on the prevous character being entered.

    Hope it helps.

提交回复
热议问题