i have this situation, i have a winform which has arround 10 to 15 lable and comboboxes which are all not visible. now at runtime i am passing a how many to of these to be activated? their name properties are from lable1 to lable16 and combobox1 to combobox16. i am using the following code only to test if i can find the controls but it seems to fail all, ho and by the was these controls and comboboxes are over a pannel.
the following is the code i used:
foreach (Control ctrl in this.Controls)
{
if (ctrl is Label)
{
MessageBox.Show(((Label)ctrl).Text);
}
}
You have actually sort of answered your own question…
You don’t find the controls in
this.Controls butPanel1.Controls🙂