Click here to Skip to main content
15,884,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a win forms app where users need to select a product code. Currently I query ALL product codes, and use the resulting datatable as the datasource for a combobox.

I like the look and feel of this: Autocomplete Menu[^]

However, apart from not really understanding the code in the article, I need the list of auto-complete items to come from a database query, and from what I can understand in the article, the items are manually added to the properties of the menuitem.

I though of running a query on the keypress event of the text box, and displaying a list box below the text box with the query results E.g.
SQL
SELECT TOP 10 ProductCode where ProductCode Like '%texBoxText%'


This seems like a messy way of doing things.

Any suggestions on how to implement something like this?

Thanks
Posted
Updated 20-Mar-14 14:08pm
v2
Comments
BillWoodruff 21-Mar-14 7:07am    
I'm not clear on the Control relationships/interactions in your UI: you mention a ComboBox, a TextBox, and a ListBox. Are you using the built-in auto-complete functionality of the ComboBox, or is it you only want to create your own auto-complete facility for the TextBox ?

The ComboBox shows ALL the product codes ... or some ... ? What exactly is entered by the user in the TextBox, and how is that used in relation to the other Controls ?
Richard.Berry100 23-Mar-14 13:12pm    
Hi Bill
I had been using the autocomplete on the combo, but unless you start with the correct characters, many combinations are excluded. EG IC501 may be incorrect, it should be U501, so I want to pick up '501' and show U501 even if IC501 was typed. Once a valid selection is chosen, then I need to get other data about that selection with another query. In other words, I want to display selectable options bvased on as query SELECT * FROM BlaBla WHERE Position Like '%TextBoxText%' if that makes sense? Did you have a look at the link?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900