I have two tab pages hosting TableLayoutPanels that I dynamically populate with labels and textboxes. The first one gets 96 labels and 96 textboxes, and its flicker is acceptable/tolerable, so I didn't bother to add a SuspendLayout/ResumeLayout pair.
However, the second one gets 96 labels and 288 textboxes, and its painting/flickering is intolerable. IOW, 192 controls seems to be okay, but 384 is decidedly not.
I was calling SuspendLayout prior to creating the controls dynamically, and then ResumeLayout in the finally block, but removed them, and voila! Like the first tabPage/TLP, the flicker is acceptable.
Why does this addition by subtraction work?
You may also try the two methods, I have listed in this thread. Hope they are not too arcane:
https://stackoverflow.com/a/15020157/1307504
This methods really suspends and resumes the layout. But you should never forget to call EndControlUpdate()
.
I use this in any generically control I am creating. I tried a lot with alling suspend and resume layout. It never worked the way I thought it should.