Take the 2-minute tour ×

I'm beginner in .net , so maybe my question will seem naive to some of you.

I need to display a some records in ChekedListBox.

I have table(Cat) in DataSet:

enter image description here

I need to display the content of the data table(color column) in ChekedListBox control.

Please any idea how it can be implemented?

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

It appears that CheckedListBox does not support binding, so this will not work as expected:

CheckedListBox1.DataSource = tempDataSet.Tables("Cat")
CheckedListBox1.DisplayMember = "Color"
CheckedListBox1.ValueMember = "ID"

You can use a Bindable CheckedListBox instead. Then you can bind at design time using the Properties window:

enter image description here

share|improve this answer
Neolisk that would actually work if you were to do the following ((ListBox)CheckedListBox1).DataSource =tempDataSet.Tables("Cat"); ((ListBox)CheckedListBox1).DisplayMember = "Color"; ((ListBox)CheckedListBox1).ValueMember = "ID; I would personally look at BindingList –  DJ KRAZE Dec 29 '12 at 15:56
@DJKRAZE: DataSource and similar are not suggested by intellisense, but they are available, so compiler won't stop you, it will even correct the case for you, without casting to ListBox. People are reporting issues with CheckedListBox though, when binding through DataSource. Here is one. –  Neolisk Dec 29 '12 at 19:32
add comment

you can follow this link:

how to bind data in checkedlistbox in window application

or try this template:

SqlDataAdapter da = new SqlDataAdapter("SELECT NAME AC_CODE FROM AccountM where compcode='" + Compcls.Gcomp_cd + "'", con);

DataSet ds = new DataSet();
da.Fill(ds, "AccountM ");
checkedListBox1.DataSource = ds;

checkedListBox1.SelectedValue = "AC_CODE";
checkedListBox1.SelectedItem = "NAME";
share|improve this answer
add comment

Let's say if you save the checkedListBox1.SelectedValue in db you can do as follow:

  1. Load you data into a data table, e.g. myDt
  2. Loop each datarow in your datatable & set the checked status based on dr value

    foreach (DataRow dr in myDt.Rows)
         checkedListBox1.SelectedValue = dr[0].ToString();
         checkedListBox1.SetItemChecked(checkedListBox1.SelectedIndex, true);

Hope this helps...

share|improve this answer
add comment

Your Answer


