Answered by:
How to set DataSource to CheckedListBox

Question
-
Hi all
I have to create a checkedListBox populating with DB values
DB values get in sizeList and have to set it the DataSource of checkedListBox
how can I do it
I have to do it as in the image
SaadieTuesday, October 11, 2011 6:53 PM
Answers
-
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/c34c85d3-a66d-4c7b-97e2-f3fc5369458f/
http://stackoverflow.com/questions/1886412/checked-list-box-data-source-does
Other options
http://www.codeproject.com/KB/grid/custCheckedListBox.aspx
http://www.codeproject.com/KB/combobox/ExCheckedListBox.aspx
Regards,
Narendran Ponpandiyan
- Proposed as answer by Hardz Tarrayo Wednesday, October 12, 2011 4:55 AM
- Marked as answer by Bob Wu-MTModerator Thursday, October 13, 2011 5:18 AM
Wednesday, October 12, 2011 3:57 AM -
Hi Saadia,
try this:
((ListBox)chkList).DataSource = _sizeList;
((ListBox)chkList).DisplayMember = "SizeName";
((ListBox)chkList).ValueMember = "SizeID";Hope this may help.
Bob Wu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Saadia Khan Thursday, October 13, 2011 4:50 AM
Thursday, October 13, 2011 1:31 AMModerator
All replies
-
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/c34c85d3-a66d-4c7b-97e2-f3fc5369458f/
http://stackoverflow.com/questions/1886412/checked-list-box-data-source-does
Other options
http://www.codeproject.com/KB/grid/custCheckedListBox.aspx
http://www.codeproject.com/KB/combobox/ExCheckedListBox.aspx
Regards,
Narendran Ponpandiyan
- Proposed as answer by Hardz Tarrayo Wednesday, October 12, 2011 4:55 AM
- Marked as answer by Bob Wu-MTModerator Thursday, October 13, 2011 5:18 AM
Wednesday, October 12, 2011 3:57 AM -
I am doing it as
((ListBox)chkList).DisplayMember = "SizeName";
((ListBox)chkList).ValueMember = "SizeID";
((ListBox)chkList).DataSource = _sizeList;but do not show SizeName but it show the namespace of Size.cs Class.
What I have made some wrong with it
SaadieWednesday, October 12, 2011 5:03 AM -
try to use
chkList.DataTextField and chkList.DataValueField
chkList.Datasource = _sizeList;chkList.databind();
Sumit KumarWednesday, October 12, 2011 9:05 AM -
Sumit its showing error that CheckedListBox does not contain definition of DatatextFeild ,DataValueField and DataSource .
SaadieWednesday, October 12, 2011 12:47 PM -
Hi Saadia,
try this:
((ListBox)chkList).DataSource = _sizeList;
((ListBox)chkList).DisplayMember = "SizeName";
((ListBox)chkList).ValueMember = "SizeID";Hope this may help.
Bob Wu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Saadia Khan Thursday, October 13, 2011 4:50 AM
Thursday, October 13, 2011 1:31 AMModerator -
Thanx Bob Wu.It worked for me
SaadieThursday, October 13, 2011 4:51 AM -
How can I read the CheckedListBox whether which is checked aur unchecked
SaadieThursday, October 13, 2011 9:33 AM -
Hi Saadia,
There is a property called CheckedItems in CheckedListBox Class. Or use CheckedListBox.GetItemChecked Method to see whether specified item is checked.
Regards,
Bob Wu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Thursday, October 13, 2011 10:00 AMModerator