View Full Version : binding a combobox to a dataset and value changes appropriately for current record


joe789
07-06-2011, 05:26 AM
Binding a combobox to a dataset and value changes appropriately for current record selected?

I have a dataset in a vb.net form that is linked successfully to a sql server table with fields from the table being displayed on the form appropriately. I have created a combobox and populated it with a collection of items the user can select from. I am attempting to bind that combobox to a field in the linked table, so that as the user navigates thru the records in the dataset the appropriate value is displayed in the combobox and if a user selects a value from within the combobox that value is automatically updated/replaced/changed in the appropriately bound field. I am wrestling with this one - any help would be greatly appreciated. Thanks!

DirtDiverKF
10-19-2011, 09:06 AM
Same issue i am having except not with sql on line, just in access

Estuardo
11-24-2011, 05:42 PM
G'd Evening!
Joe: When you bind your txtboxes you can bind your combobox as well. You just have to be sure that it is populated before binding. Then you can do something like this:
Me.cboYourCombobox.Value = CInt(YourObject("YourTableField")).
YourObject is anything that supports the IEnumerable interface, might be a dataset, datatable, arrays, a class etc.

DirtDiver:
In ms access you just have to use the Form_Current() event and set your combobox to a table's field like this:
Me.cboYourCombo = Me.txtPKField

G'd luck