Search code examples
c#winformstablelayoutpanelchecklistbox

How to add checklistbox items into tablelayoutpanel?


How to add checklistbox values into tablelayout in window from c# here is my code

cbl.Items.Add(dt.Rows[r]["Option1"].ToString());
cbl.Items.Add(dt.Rows[r]["Option2"].ToString());

Above two items I want to add them in tablelayoutpanel how to do it. I am guessing to be as

tableLayoutPanel1.Controls.Add(cbl.Items[0].ToString());

Solution

  • Try this code

    CheckedListBox cbl = new CheckedListBox();
    cbl.Items.Add("Item 1");
    cbl.Items.Add("Item 2");
    tableLayoutPanel1.Controls.Add(cbl);
    

    Hope this will help