user interface - Build list of Panels for management in C# with Rudimentary Form Builder -


i'm working in form builder allows me input select custom code. i'm trying build rudimentary window manager shows , hide's panels. i'm using .visible , system.drawing.point in form onclick:

public void togglepanel(panel panel) {     if(panel.visible)      {         panel.visible = false;     }     else      {         panel.visible = true;         panel.position = new system.drawing.point(panel1.right + 5, panel1.top);     } } 

currently closeallpanels long list of declarations, i.e. panel2.visible = false;

how can generate list of these panels? can using getmembers() method? i'm new c#, i'm not sure class i'd need run getmembers() on generate list.

or there easier way i'm missing?

if of panels in same container, like:

        list<panel> panels = new list<panel>(this.controls.oftype<panel>());         console.writeline("# of panels: " + panels.count.tostring());         foreach(panel pnl in panels)         {             console.writeline(pnl.name + ": visible = " + pnl.visible.tostring());         }  

you can replace "this" name of container if panels not directly contained form itself.

to reference panel "by name" controls.find():

        string panelname = "panel1";         control[] matches = this.controls.find(panelname, true);         if (matches.length > 0 && matches[0] panel)         {             panel pnl = (panel)matches[0];             // ... "pnl" ...         } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -