all groups > vb.net controls > august 2006 >
You're in the

vb.net controls

group:

combobox datasource visual basic .net 2005



combobox datasource visual basic .net 2005 ayaari
8/1/2006 3:29:02 AM
vb.net controls: Hi
I am initialize combobox with data source,with 3 options (1,2,3 for example).
i am doing it using this code:
Combofromver.DataSource = ds2.Tables(0)
Combofromver.DisplayMember = "customer_ver"
then am using a select statment that bring me back 1 row from other table.
the using the same code to view the result on the same comboxbox
and on the same comboxbox the value is 2.(the one row fromr the table)
and know i want to update it with the value of 3, but when i am pushing the
combox box there is only the value two.
I gess what happand is that overite the datasource with the datasource of
one row.
how can I do it diffrently?
Thanks in advanced
Alon
Re: combobox datasource visual basic .net 2005 Jim Wooley
8/1/2006 2:13:41 PM

[quoted text, click to view]

The datasource is used for populating the list. DisplayMember states which
column of the datasource will be used for displaying values to the user.
Additionally, you can use the ValueMember to assign the column with key values
for your list. Assuming you have a data structure for Gender with the following
information:

GenderCodes
Code Description
M Male
F Female
Unknown

You would set the DisplayMember to "Description" and the ValueMember to "Code".
You don't bind the control to the value from the record you are editing.
Instead, bind to the SelectedValue (both on SelectedValueChanged and TextChanged).

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

AddThis Social Bookmark Button