How to call the form inside another - Visual Studio

1

I have the parent form with a menuStrip. I already set it to isMdiContainer = True

And I have another form that I call Services.

In the Click event of the menuStrip > Service I put this:

frmCadastroServico CadastroServico = new frmCadastroServico();
CadastroServico.StartPosition = FormStartPosition.CenterParent;
CadastroServico.Show();

But still it does not open inside the main but a new window, how can I solve this?

The child form of this size is being opened:

    
asked by anonymous 20.09.2017 / 14:36

1 answer

4

You need to define the parent form of your new form:

Example:

frmCadastroServico CadastroServico = new frmCadastroServico();
CadastroServico.StartPosition = FormStartPosition.CenterParent;
CadastroServico.MdiParent = this; // < - Adicione isto
CadastroServico.Show()

To be maximized:

CadastroServico.WindowState = FormWindowState.Maximized;
CadastroServico.Dock=DockStyle.Fill;

To hide the maximize and minimize buttons:

CadastroServico.MaximizeBox = false;
CadastroServico.MinimizeBox = false;
    
20.09.2017 / 14:38