Hello,

I just started using WinForms and built the following to hide panels:

private void AppCodeHidePanels()
{
foreach(Control ctrl in this.Controls)
{
if(ctrl is Panel) ((Panel)(ctrl)).Visible = false;
}
}


I would like to move this to a class so that All my forms can use the same
code. My question is how do I reference the form that is calling it. I am
assuming that you can't use "this.Controls".

Thanks,

sck10

Re: Loop through Controls using a class by Mattias

Mattias
Thu Mar 01 14:53:20 CST 2007

>I would like to move this to a class so that All my forms can use the same
>code. My question is how do I reference the form that is calling it.

Pass it in as a parameter.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Re: Loop through Controls using a class by sck10

sck10
Thu Mar 01 15:30:41 CST 2007

Thanks Mattias,


"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:%23nnrwOEXHHA.496@TK2MSFTNGP06.phx.gbl...
> >I would like to move this to a class so that All my forms can use the
> >same
>>code. My question is how do I reference the form that is calling it.
>
> Pass it in as a parameter.
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.