How to Put a Form Inside a Form Using C#
In this tutorial, I will teach you how to add a form inside the form using C#. This method has the ability to change the display and how the form works into an MDI parent form. Then, you will see that the form displays a sunken client area with a raised border, once you set this property into
true . And in the client area, it is where all the MDI child forms placed to the parent form are displayed.
Open Microsoft Visual Studio 2015 and create a new windows form application.
Do the Form just like this.
Add another Form.
Go to Form1 and open the code view. In the code view create a method for closing and adding the form inside the form.
- private void closeChildForm()
- foreach(Form frm in this.MdiChildren)
- private void showFrm(Form frm)
- this.IsMdiContainer = true;
- frm.MdiParent = this;
Double click the “Add Form” button and call the method that you have created to execute when the button is clicked.
- private void button1_Click(object sender, EventArgs e)
- Form frm = new Form2();