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 do it with a textbox.
How do I do it?
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 do it with a textbox.
How do I do it?
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.
of course it depends on how you implement it but perhaps this is a good start:
I'm not sure this is working very well, but I think the base of this code is good enough.