Re: Resize a form in a panel
Just to correct your terminology a bit because it is very confusing; A "Form" is defined as a class derived from Form. If your control is a UserControl it is not in any way shape or form a "Form", it is a UserControl. To speak of it as a Form is incorrect as they are very different animals. forms do not have Anchor or DockStyle properties and you cannot place a form inside of a panel.
You need to anchor your panel on all sides and set the DockStyle of your UserControl to fill. If you do that they will resize with the parent form.
Re: Resize a form in a panel
I apologize for not using the correct terminology. I tried anchoring and setting the dockstyle to fill without success. This is what I have now:
Code:
UsrCtrl userCtrl = new UsrCtrl();
userCtrl.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left);
userCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
pnlXVw.Controls.Add(userCtrl);
The panel is docked in the main window. If I replace userCtrl with pnlXVw in the anchor above, my docking of the panel in the main window doesn't work correctly. It moves the panel with the window but with a 20 or so pixels in between. Also, the UserControl still doesn't move.
Re: Resize a form in a panel
In order to get the inner control to resize, you must change the size of parent panel, you know that right? The inner control will size with the parent panel.
Also get rid of all the AnchorStyle stuff, it is redundant DockStyle.Fill does the job just fine.