简体   繁体   中英

Size control on MDI child form

In my application there are two forms.

MDIParentForm
Child form

Child form contains a panel. Here is the code:

private void ChildForm_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState.Equals(FormWindowState.Maximized))
    {
        this.lPanel.Height *= 2;
        this.lPanel.Width *= 2;
    }
if (this.WindowState.Equals(FormWindowState.Normal) 
         || this.WindowState.Equals (FormWindowState.Minimized))
    {
        this.lPanel.Height /= 2;
        this.lPanel.Width /= 2;
    }

}

Now, I maximize the child form. And minimize the MDIParent Form from the task bar. Now when I restore the MDIParent, the Panel (ie in the ChildForm) expands to double as in code. Controls in child form must not expand. TIRED OF THIS.

If all you want is automatic re-sizing, why don't you use anchors? Reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.anchor(v=vs.110).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM