Looking for help with WinForms Performance issue resizing co

Mar 3 2020 3:18 AM
In a .NET Framework 4.x Form, there is a SplitContainer and in the left pane is a FlowLayoutPanel. UserControls/Custom Widget controls are added to the left pane from top down.
 
I don't think I'm resizing the Widgets correctly. In the SplitterBarMoved event, the Width property of all the Widgets are set in a foreach loop. The repaint of the Widgets is visible and looks bad. The PC running the app is a 6 Core 4.7 GHZ machine.
 
When there is one Widget, perf is fine. When there are 40, it is really slow.
 
The Widget :UserControl has a FlowLayoutPanel. In that panel there are 4 Labels. One Label will vary in length. It could be really long and needs to wrap. When it wraps, the Widget controls need to grow in Height. When the splitter is moved to accommodate more room in the left pane, the Widget width and Height need to be set.
 
I've tried turning on DoubleBuffering but that didn't help much. I've also spent far too much time trying to use the AutoSize with ExpandAndGrow. That theoretically should do all the resizing, but it does not work as expected.
 
Any tips on how to resize the Widgets in such a way that the repaint from resizing is completed quickly or correctly? 

Answers (2)