Changing ComboBox Data

S

Schamness

I am working on an application as I try to learn/work with Visual
basic.
I am writing the application in Visual Studio 2005 and am connecting
the Application to an Access Database.
I used the Visual Studio wizard to create the data connection,
datasets etc.

I currently have a compbo box that is bound to "Product Description"
from the tblProducts in my database.
All appropriate textboxes on my main form are populated correctly
whenever the combo box loads or the option in the combo box is
changed.

Now I have 2 menu items, stemming from a "Select" option.
I have Select > by Product ID and Select > by Product Description.

I would like to choose either product ID , or Product Description and
have this choice change the information bound to my combo box. So
instead of displaying product description, it would now display
Product Id, and vice versa (depending on the Select > choice).

I did not manually code the origional databind for the combo box,
however should I have to so that I can create these options I will.
Any advice is greatly appreciated.
Thank you.
 
R

RobinS

Take out the binding in design mode, and redo it in manual mode.

This one will show description, but selectedvalue will be ID. If you want
to show ID, change the DisplayMember to ProductID.

myComboBox.DataSource = myDataSet.ListByProductID
myComboBox.DisplayMember = "ProductDescription"
myComboBox.ValueMember = "ProductID"

or

This one will show and select description.

myComboBox.DataSource = myDataSet.ListByProductDescription
myComboBox.DisplayMember = "ProductDescription"
myComboBox.ValueMember = "ProductDescription"

See if that helps.

Robin S.
 

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

Top