Sam

Sam

  • NA
  • 166
  • 0

VS2008 C# 'Foreach' control selection problem

Feb 28 2012 5:34 AM

Hello,

I am trying to test a checkbox state by selecting it by its Tag.
Problem is that although the program specifically selects only Check boxes,
it will not recognize the control as a checkbox, and thus will not accept the 'Checked' property that is normal for CheckBoxes.
IMHO This seems liek a VS ignored feature.
Can anyone advice on a workaround or another way to get the same result?
foreach (Control chkbx in Controls)
{
if (chkbx.GetType() == typeof(CheckBox))
{
if (chkbx.Tag == NumUpDn3.Tag && chkbx.Checked)  << This 'Checked' not accepted!!
{ do something  }
}
}


Answers (4)