Can't find the answer to a seemingly easy question. I need to iterate through the controls on a form, and if a control is a CheckBox, and is checked, certain things should be done. Something like this
foreach (Control c in this.Controls)
{
if (c is CheckBox)
{
if (c.IsChecked == true)
// do something
}
}
But I can't reach the IsChecked property.
The error is 'System.Windows.Forms.Control' does not contain a definition for 'IsChecked' and no extension method 'IsChecked' accepting a first argument of type 'System.Windows.Forms.Control' could be found (are you missing a using directive or an assembly reference?)
How can I reach this property? Thanks a lot in advance!
EDIT
Okay, to answer all - I tried casting, it doesn't work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…