Following is a way to get all checkbox controls in a Panel named panelMainContent.
C#
private void GetCheckBoxControls()
{
LoopControls(panMainContent.Controls);
}
private void LoopControls(controlCollection)
{
foreach (Control control in controlCollection)
{
if (control is CheckBox)
{
var menuControl = (CheckBox)control;
if (menuControl.Checked)
{
//do something
}
}
if (control.Controls != null)
{
LoopControls(control.Controls);
}
}
}
0 comments:
Post a Comment