• We just launched and are currently in beta. Join us as we build and grow the community.

How to Put a Form Inside a Form Using C#

capullones

Behavioral Threat Analyst
C Rep
0
0
0
Rep
0
C Vouches
0
0
0
Vouches
0
Posts
117
Likes
121
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
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.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application.
csharp_create_app_1.png

Step 2

Do the Form just like this.
maindfrmcsharp.png

Step 3

Add another Form.
psaddformcsharp.png

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.
  1. private

    void

    closeChildForm(

    )
  2. {
  3. foreach

    (

    Form frm in

    this

    .

    MdiChildren

    )
  4. {
  5. frm.

    Close

    (

    )

    ;
  6. }
  7. }

  8. private

    void

    showFrm(

    Form frm)
  9. {
  10. this

    .

    IsMdiContainer

    =

    true

    ;
  11. frm.

    MdiParent

    =

    this

    ;
  12. frm.

    Show

    (

    )

    ;
  13. }

Step 5

Double click the “Add Form” button and call the method that you have created to execute when the button is clicked.
  1. private

    void

    button1_Click(

    object

    sender, EventArgs e)
  2. {
  3. closeChildForm(

    )

    ;
  4. Form frm =

    new

    Form2(

    )

    ;
  5. showFrm(

    frm)

    ;

  6. }

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

 

452,292

323,526

323,535

Top