Check all checkboxes in checkboxlist with one click using c#

后端 未结 6 966
傲寒
傲寒 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:02

    Try this:

     foreach(Control c in this.Controls) {
        if (c.GetType() == typeof(CheckBox)) {
           ((CheckBox)c).Checked = true;
        }
     }
    

提交回复
热议问题