binding to a combo box

G

Geraldine Hobley

Hello,
I have a problem binding a combo box to a datasource.
The datasource is called dsstatus and consists of two
columns Projectstatuskey and ProjectStatus
The displaymember is projectstatus (all the descriptions)
All the fields on the form are bound to a class called
projList

a normal text field is bound as follows
MyProjectInfo.ProjectCode.DataBindings.Add("text",
ProjList, "Projectcode")
This works fine.


MyProjectInfo.cmbStatus.DataSource = dsStatus.Tables!
Projectstatus.DefaultView

However I wish to bind the valuemember of the combobox
cmbstatus like below and I just get an error message
saying that I cannot bind to valuemember. If I bind to
text in the combo field it just displays the index keys
and not the desciptions and it is not updated when I
select a value from the dropdown list.

MyProjectInfo.cmbStatus.DataBindings.Add("ValueMember",
ProjList, "status")

'list works fine'
MyProjectInfo.cmbStatus.DisplayMember = "ProjectStatus"

Any ideas would be appreciated

Geraldine.
 
O

One Handed Man [ OHM# ]

With a comboBox you bind the DataSource to lets say the DataTable, the
DisplayMember to the field you want to display, and then you use the
selectedValue to retreive the Valuemember Value,

I dont see what you are trying to acheive really

OHM




Geraldine said:
Hello,
I have a problem binding a combo box to a datasource.
The datasource is called dsstatus and consists of two
columns Projectstatuskey and ProjectStatus
The displaymember is projectstatus (all the descriptions)
All the fields on the form are bound to a class called
projList

a normal text field is bound as follows
MyProjectInfo.ProjectCode.DataBindings.Add("text",
ProjList, "Projectcode")
This works fine.


MyProjectInfo.cmbStatus.DataSource = dsStatus.Tables!
Projectstatus.DefaultView

However I wish to bind the valuemember of the combobox
cmbstatus like below and I just get an error message
saying that I cannot bind to valuemember. If I bind to
text in the combo field it just displays the index keys
and not the desciptions and it is not updated when I
select a value from the dropdown list.

MyProjectInfo.cmbStatus.DataBindings.Add("ValueMember",
ProjList, "status")

'list works fine'
MyProjectInfo.cmbStatus.DisplayMember = "ProjectStatus"

Any ideas would be appreciated

Geraldine.

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 

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