how loop through multiple checkbox in C#

前端 未结 6 1051
后悔当初
后悔当初 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:40

    foreach (var box in this.Controls.OfType())
    {
        if (box.Checked)
        {
            //...
        }
        else
        {
            //...
        }
    }
    

提交回复
热议问题