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