• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

Maximized MDI Form Problem

I like to have a MDI Child Form maximized in the parent form

Now when the parent form ist sized smaller than the child minimal formsize, the parent form should get scrollbars. If the child form is not maximized it works. How can i do this that it also works in maximized mode ?

regards
Chris
0
zeebee
Asked:
zeebee
  • 3
  • 2
1 Solution
 
Bruce_1975Commented:
Try this:
don't place the controls directly on the form. Use a panel instead with AutoResize = true;
Place the Panel on the child form with Dockstyle Top.

Regards,
Bruce
0
 
zeebeeAuthor Commented:
Are there any other solutions because its a very hugh project where the forms are loaded very differently and i can't change every form.

is this a solution which can be added dynamically when showing the form ?
0
 
Bruce_1975Commented:
Took a while but finally I got it.
You can overload the OnLoad function of the child forms.
protected override void OnLoad(EventArgs e)
{
    Panel pnlMaster = new Panel();
    pnlMaster.Dock = DockStyle.Fill;
    pnlMaster.AutoScroll = true;
 
    while (this.Controls.Count > 0)
        pnlMaster.Controls.Add(this.Controls[0]);
 
    this.Controls.Add(pnlMaster);
    base.OnLoad(e);
}

Open in new window

0
 
zeebeeAuthor Commented:
ok this works well on a small testform. i try this in the big project on monday. thanks for this solution.

if anybody other have some solution which can be done more from outside the child form i will be pleased to hear.
0
 
Bruce_1975Commented:
Hmm..
at my first post i mixed up AutoResize and AutoScroll... sorry for that.

Have a nice weekend!

Regards,
Bruce
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now