I would like to add a dynamic CheckAll()
method to check all checkboxes declared in my class.
I tried following code:
class MyContol : UserControl
{
///
/// HIDDEN but there is plenty of checkboxes declaration
///
private void CheckAll()
{
FieldInfo[] props = this.GetType().GetFields();
foreach (FieldInfo p in props)
{
if (p.FieldType is CheckBox)
{
/// TODO: Check my box
}
}
}
}
... but props
is empty. I have no idea how to target checkboxes made with designer part.
Do you know using Reflection
how to target added by design view components?