Check all checkboxes in checkboxlist with one click using c#

后端 未结 6 847
傲寒
傲寒 2021-02-03 22:46

I want to have a button that once clicked, it will select all checkboxes in my checklistbox. I\'ve search the possible answers but I always see examples for asp.net and javascri

6条回答
  •  一个人的身影
    2021-02-03 23:12

    what I did is I put it inside of a tableLayoutPanel, I fixed all the checkboxs in the 3rd column and i added the event:

    private void cbCheckAllCHECKBOXs_CheckedChanged(objects sender, EventArgs e)
    {
        if (cbCheeckAllCHECKBOXs.Checked)
        {
            for (int i = 0; i < tlpCHECKBOXsControlPanel.RowCount; i++)
            {
                ((System.Windows.Forms.CheckBox)(tlpCHECKBOXsControlPanel.GetControlFromPosition(3, i))).Checked = true;
            }
        }
    }
    

提交回复
热议问题