AutoComplete TextBox Control

前端 未结 9 1281
误落风尘
误落风尘 2020-11-27 04:48

I want to have a textbox control that suggests and append values from a database in a Windows application with C# 2008 and LINQ.

I do it with a combobox but I can\'t

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 05:30

    You could attach to the KeyDown event and then query the database for that portion of the text that the user has already entered. For example, if the user enters "T", search for things that start with "T". Then, when they enter the next letter, for example "e", search for things in the table that start with "Te".

    The available items could be displayed in a "floating" ListBox, for example. You would need to place the ListBox just beneath the TextBox so that they can see the entries available, then remove the ListBox when they're done typing.

提交回复
热议问题