How to call the form inside another - Visual Studio

Asked

Viewed 2,621 times

1

I have the parent form with a Trip menuStrip. I’ve already set him up as isMdiContainer = True

And I have another form I call Services.

In the event MenuStrip > Service I put this:

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

But still it doesn’t open inside the main but a new window, how can I fix it?


The child form of this size is being opened: inserir a descrição da imagem aqui

1 answer

4


You need to set the parent form (Parent) of your new form:

Example:

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

To make it maximized:

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

To hide buttons maximize and minimize:

CadastroServico.MaximizeBox = false;
CadastroServico.MinimizeBox = false;
  • thanks bro solved.. Is there anything I can do for him to open the window size (dad)? No maximize buttons minimize etc

  • Okay, I edited with example to get to this

  • Look how it turned out, I edited the question and put the image.. It will be because I need to get exactly the size of the parent form field?

  • 1

    Before the CadastroServico.Show() add CadastroServico.Dock=DockStyle.Fill;

  • It worked, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.