Connecting Tech Pros Worldwide Help | Site Map

Populating CheckedListBox DataTable + C# form

JustRun's Avatar
Member
 
Join Date: Mar 2008
Posts: 110
#1: Oct 20 '09
Hi all,

I have a problem with populating a CheckedListBox from dataTable, I dont know the properties that bind the displayMember and valueMember
Using windows application .NET 2005 with Sql 2005

Thanks
Familiar Sight
 
Join Date: Jul 2009
Location: Calgary, Alberta, Canada
Posts: 218
#2: Oct 20 '09

re: Populating CheckedListBox DataTable + C# form


Well, I'm looking at the MSDN page for a CheckedListBox class...
http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx

They provide a table that represents what the collection of items look like. Basically, three columns that are the Index, Item, and the CheckState (which I think can be represented as an integer). Have you tried creating a DataTable of this format and then linking it to the DataBindings member?

This has been thrown around these forums before, but in general using a direct binding seems to cause you to lose a bit of control. It depends on what you want to do, but it might be worth considering reading your database table to build the CheckListBox, then when it's time to write back in, read from the CheckListBox to write back into your table. Basically, handle the data binding your self.

Anyway, good luck!
Reply