How to Put a Form Inside a Form Using C#
Submitted by janobe on Monday, November 26, 2018 - 20:57.
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
For more question about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
FB Account – https://www.facebook.com/onnaj.soicalap
Or feel free to comment below
true
. And in the client area, it is where all the MDI child forms placed to the parent form are displayed.
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form application.
Step 2
Do the Form just like this.
Step 3
Add another Form.
Step 4
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)
- {
- frm.Close();
- }
- }
- private void showFrm(Form frm)
- {
- this.IsMdiContainer = true;
- frm.MdiParent = this;
- frm.Show();
- }
Step 5
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)
- {
- closeChildForm();
- showFrm(frm);
- }
Add new comment
- 1562 views