BindingSource vs. old binding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm getting myself confused about the new BindingSource. In the old days I'd
bind a combobox like this to show the "productName" field:

DataSet ds = getDS();
cboX.DataSource = ds.Tables["Products"];
cboX.ValueMember = "productID";
cboX.DisplayMember = "productName";

Now I guess I can do this:

BindingSource bs = new BindingSource(getDS(), "Products");

which sets the bs.DataSource and the bs.DataMember (ie the table within the
dataset).

But, how do I tell it what field to display when the table has multiple
fields? There is no longer any DisplayMember or ValueMember property.
 
Doh! I just realized the BindingSource simply substitutes as the DataSource
for a control. But the other control properties still exist and are used -
namely:

cboX.ValueMember = "productID";
cboX.DisplayMember = "productName";
cboX.DataSource = new BindingSource(getDS(), "Products");

Tim
 
Back
Top