binding a combobox to dataset

G

Geraldine Hobley

Hello,
I have a combobox on my form called "cmbstatus". I
wish the display values to be taken from a look up table
in a dataset "dsstatus" called Projectstatus with the
description field Projectstatus containing the values to
be displayed.

MyProjectInfo.cmbStatus.DataSource = dsStatus.Tables!
Projectstatus.DefaultView
MyProjectInfo.cmbStatus.DisplayMember = "ProjectStatus"

However I wish to bind the combobox to a collection
called Projlist and inparticular a property
called "status" which contains the Projectstatuskey from
the main database table (as supposed to the lookup dbtable)

What do I set the cmbstatus ValueMember to.

I've tried
MyProjectInfo.cmbstatus.databindgings.add
("valuemember",Projlist,"status") which is how I bind my
text boxes successfully, but it won't let me do this.

also what do bind the selectedvalue to.

Any help would be greatly appreciated.

Regards
Geraldine
 
K

Ken Tucker [MVP]

Hi,

The combobox displaymember and valuemember must be from the
datasource. Dont forget to add a displaymember. To bind to a collection
this will work.

MyProjectInfo.cmbStatus.DataSource = projlist
MyProjectInfo.cmbStatus.DisplayMember = "Status"
MyProjectInfo.cmbStatus.ValueMember = "Status"

Ken
 

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