Use a Windows Form as the main

1

Good morning,

I am working with Windows Form within C #, which I am working on a module for the company that starts like this at the moment of initialization:

Which would be the index.

Just to the upper right is a button that is called "exam" in which I intend that by pressing it you can see the following:

Which is found in another Windows Form. From here my question is that what I want is that the form can be seen inside the white area, I only had the doubt if I have to make different Windows Form with the same style of the index, because the module "examination" is one of several that Then I would like to know if there is any way to not create so many Windows Forms, watch user control videos but I do not understand much because I have never handled them, if you could help me.

Annex a photo of what I intend to do.

Thank you.

    
asked by Ezequie Lopez 03.08.2018 в 01:08
source

3 answers

1

1) In your main form you must mark it as MDIContainer

2) You must add a menuStrip to maintain a menu on your main form, and within the add your button.

3) In the click event of the button in your menu we invoke the form, maximized.

private void button1_Click(object sender, EventArgs e)
        {
              Form2 newMDIChild = new Form2
              {
                MdiParent = this,
                WindowState = FormWindowState.Maximized
              };
              newMDIChild.Show();
        }

The result would be:

    
answered by 03.08.2018 / 17:44
source
2

Uses MDI container and MDI Parent properties

with those the "Main Form" becomes a container for all the new forms that you create where the "mdi parent" is the main form

    
answered by 03.08.2018 в 17:14
2

Good morning!

1. Initially you will have to create the new Forms which you want to be contained in the Form index (In this case it would be the Exam form) .

2. You can use MDI Containers that will work as secondary Forms or children of the main Form.

  • A new instance of the FormChild will be created, which in your case will be Exam inside your Form index.

I leave you a short example, I hope it serves you!

Greetings!

private void btnExamen_Click(object sender, EventArgs e)
{
    this.IsMdiContainer = true;
    Form FormChild = new Form();
    FormChild.MdiParent = this;
    FormChild.Show();
}
    
answered by 03.08.2018 в 17:25