how loop through multiple checkbox in C#

前端 未结 6 1047
后悔当初
后悔当初 2021-01-14 00:06

I have 100 checkbox in a winfrom. Their name is sequential like checkbox1,checkbox2 etc. I have a submit button in my winform. After clicking the submitting button, it check

6条回答
  •  北恋
    北恋 (楼主)
    2021-01-14 00:47

    foreach (var ctrl in panel.Controls) {
        if (ctrl is CheckBox && ((CheckBox)ctrl).IsChecked) {
            //Do Something
        }
    }
    

提交回复
热议问题