Windows Develop Bookmark and Share   
 index > Windows Forms General > MDI child form to maximize to the size of parent free space
 

MDI child form to maximize to the size of parent free space

Hi

When you create a mdi application. You will have your mdi parent. Then you have the child forms. But when you maximize the child form it sort of merges/overlaps with the toolstrip on the mdi parent.

  • is there a way to make sure that the mdi child maximum size is the size of that available dark space in the mdi parent. Not to merge or overlap the toolstrip!!

Thanks in advance 

LuckyL  Friday, December 15, 2006 2:40 PM
Nope, looks all perfectly normal to me and I don't see any overlap. You're possibly complaining about the menu strip moving down, making room for the maximized MDI child's icon and max/min/close buttons. That's normal MDI behavior and can't be altered...
nobugz  Saturday, December 16, 2006 6:39 AM
This is not normal behavior. Try to reproduce this in a minimal app and post the designer code so we can try it ourselves.
nobugz  Friday, December 15, 2006 5:35 PM

Hi NoBugs

It is actually very common behaviour, does it in C# and VB. But it shouldn't because and mdi application you would but on the market will not do this.

Here is my code for a mini try. Click on "file" in toolstrip to make child form. Then when you click maximize on the child form you will see that it actualy overlaps the toolstrip and moves it down. I want it to be only able to maximize until beneath it.

using System;

using System.Collections.Generic;

using System.Text;

using System.Windows.Forms;

namespace WindowsApplication1

{

class Class1:Form

{

public MenuStrip MenuStr = new MenuStrip();

public ToolStripMenuItem FileMenItem = new ToolStripMenuItem();

public Class1()

{

this.Name = "Parent";

this.IsMdiContainer = true;

this.Width = 500;

this.Height = 500;

MenuStr.Location = new System.Drawing.Point(0, 0);

MenuStr.Size = new System.Drawing.Size(292, 24);

MenuStr.TabIndex = 0;

MenuStr.Name = "MainMenuStrip";

MenuStr.Enabled = true;

MenuStr.Visible = true;

FileMenItem.Size = new System.Drawing.Size(35, 20);

FileMenItem.Text = "&File";

FileMenItem.Name = "File";

MenuStr.Items.AddRange(new ToolStripItem[] { FileMenItem, });

this.Controls.Add(MenuStr);

FileMenItem.Click+=new EventHandler(FileMenItem_Click);

//BuildChildForm();

}

private void FileMenItem_Click(object sender, System.EventArgs e)

{

BuildChildForm();

}

private void BuildChildForm()

{

Form cf = new Form();

cf.MdiParent = Application.OpenForms["Parent"]; //"Parent";

cf.Width = 100;

cf.Height = 50;

cf.Show();

}

}

}

Thanks in advance

LuckyL  Saturday, December 16, 2006 5:51 AM
Nope, looks all perfectly normal to me and I don't see any overlap. You're possibly complaining about the menu strip moving down, making room for the maximized MDI child's icon and max/min/close buttons. That's normal MDI behavior and can't be altered...
nobugz  Saturday, December 16, 2006 6:39 AM

Hi nobugz

Yes, that is exactly what i'm talking about. I do not want the menustrip to move down. I want the clients to only go as big as the clientrectangle when clicked on maximize. Is there no way??? if you try to use MaximizedBounds on the child form it seems to ignore it totaly.

Any way around this???

Thanks in advance

LuckyL  Saturday, December 16, 2006 2:04 PM
Wow - thats frustrating. Would be nice if there could be a property like HideIcon that you could set to true for MDI Children. Or the old way where the menu slid to the right of the childs Icon. Maybe VS2008
WillieD123  Wednesday, July 25, 2007 6:47 PM
I found a way to do this since I made that last post. Right-click the toolbox, Choose Items, take a couple of sips of coffee, select ToolStripPanel. Drag and drop it onto a form. Enlarge it a bit. Drop a MenuStrip onto that panel. Right-click it, Select, toolStripPanel1. Set the TSP's Dock property to Top. Create your menu and do everything else to make your MDI Parent.

Now when you maximize an MDI child, the menu will merge with the MDI icon bar. Not sure why it is such a big secret, other than that TSP can be *very* awkward in the designer. If you don't do it just right, you'll get in big trouble.
nobugz  Wednesday, July 25, 2007 7:11 PM

Hey, that actually works! THanks for the tip. I tried editing my existing MDI Parent, cuting and pasting the menu and icon strip and that didnt work. But doing it on a new form like you describe does work. Thats a fine thing because I cant see the users going for all that used up space on their screens.

Thanks

WillieD123  Wednesday, July 25, 2007 10:31 PM

You can use google to search for other answers

Custom Search

More Threads

• MaskedTextBox help
• Change notify icon depending on visible or not
• reorder listview based on Tag
• how to implement (shift | Mouse) Click select in Data Grid?
• Microsoft Sql Server Reporing Service
• HOW CAN I DESIGN MY OWN TOOLBOX CONTROL
• Parent form control access
• Setup Project Question
• Child node alignment in MS TreeView
• How to check existing windows application is vista compatible?