I got many panels and one form. I have employed panels so I don’t have to use multiple forms. But there is a problem with it. After I assign the panel size to the form size and show the form, the next time I assign it again, and to my surprise the panel gets smaller than the original. Why is this happening? Here is how I’m doing it.
this.Size = panelABC.Size;
panelABC.Dock = DockStyle.Fill;
panelABC.Visible = true;
Because the panel size has changed in relation to the control it is docked within by the time you come to call this code again. Using docking or anchoring will manage the panel size during resizing of parent containers.
For answer clarity – the actual answer is described in the comments of another posted answer.