C# TabPages added at runtime don’t autosize the parent form

autosizecruntimetabpage

I have a simple form that contains a TabControl where the TabPages are added at runtime. I have gotten all of this to work almost as I want it to, however when I set the form to autosize, it ignores the runtime TabPages in the calculation… How can I either force the form to delay the autosizing until the TabPages have been added, or force the form to recalculate when a new TabPage is added?

EDIT: For the record, I'm testing this out by starting my app at 640×480 (using the MinimumSize property) and including a control that is 750 wide.

Best Answer

Would using the SuspendLayout() and ResumeLayout() do the trick? Here's the link that explains how it works.

You call SuspendLayout() first, add the tab pages, then ResumeLayout().

Hope this helps, Best regards, Tom.

Related Topic