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

문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top