How can I iterate through all checkboxes on a form?

后端 未结 6 874
[愿得一人]
[愿得一人] 2020-11-29 08:36

I have a form that has many dynamically generated checkboxes. At runtime, how can I iterate through each of them so I can get their value and IDs?

6条回答
  •  旧巷少年郎
    2020-11-29 09:12

    Like this, maybe (if it's in Windows Forms):

    foreach(var checkBox in myForm.Controls.OfType())
    {   
       //Do something.
    }
    

提交回复
热议问题