I am trying to resize a a form that I put inside a panel so that when the panel's window is maximized or resized, the form will size along with it. Currently, I have the form class as UserControl instead of Forms because this is the only way I could get it to work. The panel is docked center in the main window and the form is called by clicking a node in the tree docked on the left. The code I use to show the form is:

Code:
WinForm winfrm = new WinForm();
pnlXVw.Controls.Add(winfrm);
I am unsure if the UserControl is correct. The code is from the form.

Code:
public partial class WinForm : System.Windows.Forms.UserControl
I have tried anchoring the form and setting the dockstyle of the form to fill. I haven't been successful with either of these. Also, I have tried setting the panel (pnlXVw) so that the form (winfrm) but can't figure out how to do that correctly. Thanks in advance!