BindingSource vs. old binding

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.
 
G

Guest

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
 

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