Sorry Mika, I still think I'm being thick (and thanks for formatting my code - I worked out how to do that now ;-)) - your assumption is correct. What I want to do is to parse through all the instances of my user controls and take various actions depending upon the values or state (in the case of checkboxes) of their contents. This may include altering the displayed values in the user controls.
int ctr;
PropertyInfo[] checkprop;
for (ctr = 0; ctr < myflowlayoutpanel.Controls.Count; ctr++)
{
foreach (Control c in flpselect.Controls[ctr].Controls)
{
Type mytype = typeof(myfrmlist);
checkprop = mytype.GetProperties();
}
}
If I do this, checkprop gets filled with a whole stack of properties for each control in the user control...as an alternative...
PropertyInfo checkprop;
...
checkprop = mytype.GetProperty("Displayed");
...
Does the same but only for the control I'm interested in at the moment - this is a CheckBox control, so I wish to be able to read or write the CheckedState property. But I still can't see where in the list of properties that is returned where I can access that property.
Thanks again.
Aero.
Figured out what was suggested earlier by Mika by casting the control....here's what worked for me....
foreach (Control ctrl in myflowlayoutpanel.Controls)
{
myfrmlist c = ctrl as myfrmlist;
if (c != null)
{
if (c.Displayed == CheckState.Checked)
{
somestuff();
}
else
{
someotherstuff();
}
}
}
Thanks to all.
Regards,
Aero