dotnetmonitor.com

 
Index
Previous
Next

 

Problem: Someone has a form which has a panel which swaps in and out. When swapping panels, Controls.Clear() is used to clear off the old panel.

This is inefficient as it:

         Forces a layout - the Panels parent is set to null, which causes a ParentChanged, which results in a layout

         Leaks resources as the Panel is no longer associated with the form and will hold open USER32 handles.

 

Solution: There are a couple of solutions, depending if youre done with the panel or not.

         If youre not done with the panel just set it to be Visible=false

         If youre done with the panel call dispose on it.

Terms
Docking Anchor Layout
What happens when I have Dock and Anchors that conflict?
Dock Scenarios
Padding Margin
You have a perf problem with Layout - how to diagnose?