Reputation: 852
i've added a checkbox to a checkedlistbox using the following code:
CheckBox cb = new CheckBox();
cb.Enabled = false;
cb.Text = "A B C D";
checkedListBox1.Items.Add(cb);
but, as seen in the picture, the text wont show up. what have I done wrong ? Thanks!
Upvotes: 1
Views: 2480
Reputation: 121
You don't have to add a CheckBox
control to the CheckedListBox
. Just add text (Item
).
checkedListBox1.Items.AddRange(new String[]{"A","B","C"});
Hope this helps.
Upvotes: 0
Reputation: 262929
You should only add text and not a CheckBox
control. The CheckedListBox control will create the check boxes itself:
checkedListBox1.Items.Add("A B C D");
Upvotes: 3