CheckBox inside a listbox in windows form

14,777

In short: You need to use the CheckedListBox Control (Windows Forms).

Here is a sample code for Windows forms application:

private void Form1_Load(object sender, EventArgs e)
    {
        var items = checkedListBox1.Items;
        items.Add("Perls");
        items.Add("Checked", true);
    }
Share:
14,777
Nitin Singh
Author by

Nitin Singh

Updated on June 13, 2022

Comments

  • Nitin Singh
    Nitin Singh almost 2 years

    Possible Duplicate:
    CheckBox inside ListBox
    How to insert a check box inside a list box in C#?

    I would like to add check-boxes inside a list-box, in windows from application.

    Here is my code:

    CheckBox cb = new CheckBox();
    while (dr.Read())
    {
    
        listBox1.Items.Add(String.Format("{0} {1}",cb,dr["Stu_Name"]));
    }
    

    However, it is not producing intended result.

    What i want is a check-box before each column value from the data reader? Any suggestions?