Loop through Controls using a class

  • Thread starter Thread starter sck10
  • Start date Start date
S

sck10

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
 
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
 
Back
Top