populating a checkedListBox with a dataset : newbie question

M

Malcolm

I am trying to populate a CheckedListBox from a dataset and it's just
not working for me.

I have no problem hooking a dataGrid up to a dataSet.

I found an article at
http://www.dotnet247.com/247reference/msgs/1/5631.aspx
that basically said

*******************************
Set the DataSource and DisplayMember properties of the CheckedListBox
as shown below:

CheckedListBox1.DataSource = DataSet1.Tables("Suppliers")
CheckedListBox1.DisplayMember = "ProductName"
*******************************

My only problem with this solution is that in 2003 checkedListBoxes
DON'T HAVE a DataSource OR a DisplayMember method.

Did they used to in prior versions of VS.Net? And more importantly,
how do I get this done.

I'm thinking about scrapping the checkedListBox solution to my problem
set even though it is EXACTLY what the customer would like to have,
and of course it bothers me that I can't figure out how to get it to
do what I think it should be able to do.

The only thing I can think of is to take the dataSet and figure out
how to pop each record out of it, one at a time, and insert it into
the list box with the Add method. (or AddRange if I can figure out
how to dump the contents of a dataSet to an array).

TIA

Malcolm




"Bother," said the Borg, "we just assimilated Pooh."
 
C

chris

Malcolm said:
I am trying to populate a CheckedListBox from a dataset and it's just
not working for me.

<note>"ds" is a DataSet the has been filled already</note>

for(int i = 0; i < ds.Tables[0].Rows.Count; i++){
//add items unchecked
this.checkedListBoxName.Items.Add(ds.Tables[0].Rows[0], false);
}
 

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