S
Simon Verona
I posted this in dotnet.languages.vb.controls but thought I'd post here as
well..
I have a combobox that is bound to a dataview generated from a dataset.
The dataset has a single table (called "Data") with two columns "Id" and
"Description". Id contains a code and description contains the
description that is displayed in the combobox.
The dataview is generated from the dataset using dv =
ds.Tables("Data").DefaultView.
The Combobox is bound using :
txtLookup.DataSource = dv
txtLookup.ValueMember = "Id"
txtLookup.DisplayMember = "Description"
This works fine, I can read the current "Id" from the combobox using the
txtlookup.selectedvalue property.
However, if I want to programatically set the starting value of the
combobox, I can't seem to work out how to do it. I thought I could just set
the selectedvalue property to any of the vaules of "id" and the combobox
would then display the corresponding description. This appears not to be
the case. I don't know if it is getting confused by the fact that the "Id"
field in the datatable is numeric or if I'm just doing it wrong!
What should I be doing?
Thanks in advance
Simon
well..
I have a combobox that is bound to a dataview generated from a dataset.
The dataset has a single table (called "Data") with two columns "Id" and
"Description". Id contains a code and description contains the
description that is displayed in the combobox.
The dataview is generated from the dataset using dv =
ds.Tables("Data").DefaultView.
The Combobox is bound using :
txtLookup.DataSource = dv
txtLookup.ValueMember = "Id"
txtLookup.DisplayMember = "Description"
This works fine, I can read the current "Id" from the combobox using the
txtlookup.selectedvalue property.
However, if I want to programatically set the starting value of the
combobox, I can't seem to work out how to do it. I thought I could just set
the selectedvalue property to any of the vaules of "id" and the combobox
would then display the corresponding description. This appears not to be
the case. I don't know if it is getting confused by the fact that the "Id"
field in the datatable is numeric or if I'm just doing it wrong!
What should I be doing?
Thanks in advance
Simon