"Amil" <Amil@discussions.microsoft.com> schrieb:
> How can I loop thru the controls in my usercontrol? My
> usercontrol adds a label everytime you click on the button
> and there can be none of more than one labels. Using
> foreach requires that the collection is of the same type.
If you are not nesting controls, you can use this code:
\\\
foreach (Control c in this.Controls)
{
if (c is Label)
{
Label cc = (Label)c;
...;
}
else if (c is Button)
...;
}
///
If you set the controls' names, you can uniquely identify the controls...

Signature
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/
Amil - 13 Oct 2004 20:13 GMT
Thanks Herfried. It works.
> "Amil" <Amil@discussions.microsoft.com> schrieb:
> > How can I loop thru the controls in my usercontrol? My
[quoted text clipped - 18 lines]
>
> If you set the controls' names, you can uniquely identify the controls...