Combobox question

  • Thread starter Thread starter Stan Sainte-Rose
  • Start date Start date
S

Stan Sainte-Rose

Hi,

A simple question..
I have a datatable with 2 fields (SkuCode, ItemName)

I use a Combobox where the datasource is the DataTable and the DisplayMember
is the ItemName.
I add a TextBox where the user can type the SkuCode.
I would like to select the line in the ComboBox if the record exists.
I can not use the FindString method because the DisplayMember is not the
SkuCode.

Stan.
 
Hi I try not to bind to datatables or dataviews directly

But this should work
Create a dataview based on the datatable
Bind the combobox to the dataview you should see all the items
then filter your dataview based on the text typed into the textbox

Else

This is what I do
Create a structure to contain the SkuCode and the DisplayMember
make the tostring return the DisplayMember
Add any enumirator etc you might want

Create a structure for each record and add it to a collection
then bind to the collection


you can then do something like this in say the textbox validated event

Dim t As Test = x(TextBox1.Text)

ComboBox1.SelectedItem = t

Assuming Test is the name of the structure and x is the name of the
collection
and you type a sku code in the textbox 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top