How can I set the size of the child form base from the free space of the mdi container form in C#?

StackOverflow https://stackoverflow.com/questions/13965040

Pergunta

My problem is that I want the child form to occupy the free space of the MDI container

Here's the code I tried

In my MDI container form load event I have this line of code calling the child form

childform = new ppt.MyChildForm();
            childform.MdiParent = this;
            childform.Size = childform.MdiParent.ClientSize;
            childform.Show();

But what happen is that I think the child form is larger than its parent because it contains a scrollbar how can I fix this?

enter image description here

Foi útil?

Solução

If AutoSize property is set to true, changing of Size has no effect.
A better practice is to set the Dock property of the child form to DockStyle.Fill. It will always fill the entire client size of its parent, so you have not to worry about parent resizing.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top