RanH
RanH

Reputation: 852

checkbox text (inside a checkedlistbox) wont appear

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!

alt text

Upvotes: 1

Views: 2480

Answers (2)

OopsDev
OopsDev

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

Frédéric Hamidi
Frédéric Hamidi

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

Related Questions