I have a table with 28,000 names. I have loaded a combobox via a datareader. I would like to be able to do a lookup by navigating the the name in the combobox, then click on it and display the record -- I have done this in Access.
Does anyone have a sample on how to get a loaded combobox to move to the appropriate record when you click on one of the choices....like the Access combobox.
In my access apps, I have a lookup (combobox loaded with customer names) you simply click on the name, and that record loads...I want to do the same thing in VB.NET
I am doing this in an application I am converting from Access to VB.Net.
I have a dataset that contains the location names and unique record key that I want to use in my combo box (key is optional but speeds up reading). The second dataset has the data I want displayed on the form and the select query has 1 parameter (the record key).
The combo box is populated from dataset1 where the datasource is ds1 and the displaymember is Location. The valuemember is the unique key tied to the location.
On the cboField_selectedvaluechanged event add this code:
ds2.Clear()
da2.SelectCommand.Parameters("Project_Nbr").Value = cboField.SelectedValue
da2.Fill(ds2)
cboProjectSelect.Focus()
This will select whatever record from ds2 that matches whatever the user selected in the combo box. Of course you should change the names of the fields in this example to be meaningful to your application...
Set the datasource to the lookup table
Set the Displaymember to the field looking up
Set the Value member to the field that gets carried to the new table
Set the databindings text to the table and field that gets the valuemember carried to.
After you get this working go to this link and download a better autocompletecombobox to use. (it fills in automatically when you start typing) There are lots of freeware comboboxes on the net that do a great job of sorting and autofilling.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.