Combo Help

G

Guest

Hi,

Does anyone have an example code snippet from a Windows App that loads a
field from a strongly typed DataSet into a Combobox? Even dissecting the
DataSet via the Immediate Pane I still can't work out what part of the
DataSet I need to load.

Thanks very much.

Andy
 
C

ClayB

Maybe code like this will work for you.

// Attach dataset.DataTable's DefaultView to the
combobox
comboBox1.DataSource =
dataSet.Tables["customers"].DefaultView;
comboBox1.DisplayMember = "CustomerID";

==============
Clay Burch
Syncfusion, Inc.
 
R

RobinS

You should have fields listed in the code-behind for your strongly typed
dataset.

If you are using data binding, you can bind the ValueMember and
DisplayMember to the appropriate fields. For example, for a Customers
dataset, I might set them like this:

CustomersDataSet dataSource = new CustomersDataSet();
CustomersTableAdapter adapter = new CustomersTableAdapter();
adapter.Fill(dataSource);
myCombo.DataSource = dataSource.Customers;
myCombo.DisplayMember = "CompanyName";
myCombo.ValueMember = "CustomerID"

Is that what you mean, or do you want to literally load them?

Robin S.
 
G

Guest

Thanks - I've worked out how to do this - I didn't want to bind them directly
- I go through the list adding them as I need to but thanks for replying.
 

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