?
Solved

Form Automatically Maximising in MDI Parent

Posted on 2011-10-12
14
Medium Priority
?
398 Views
Last Modified: 2012-05-12
I have created a form in VS2010

The only things that i have changed from the defult on the form are to set the forms MDIParent, set "ControlBox = False" and "StartPosition = Center Screen"

when i open the form it opens in the MDI Container but fills the screen rather than just being its set size and being positioned centrally.

can anybody tell me why?
0
Comment
Question by:ict-torquilclark
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 40
ID: 36956581
The Location, Size and StartPosition are disregarded when WindowState is Maximized.

The form you are opening as a child probably has its own WindowState property set to Maximized.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36956615
Can you show some code?...I can't reproduce the problem:  
private void button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
            f2.ControlBox = false;
            f2.StartPosition = FormStartPosition.CenterScreen;
            f2.MdiParent = this;
            f2.Show();
        }

Open in new window

Idle-Mind-511440.flv
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36956635
*If you have other MdiChildren already displayed in a Maximized state, then new MdiChildren would also display Maximized.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:ict-torquilclark
ID: 36960811
i do already have an mdi child object maximised, so that is what causes it :o)

Is there a way to make the new form display not maximised, whilst having the other fom open maximised?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36960996
I think you either have all forms maximized or all in normal state. One option is to show this form as modal.
0
 
LVL 1

Author Comment

by:ict-torquilclark
ID: 36961012
i didnt know that was still possible...

form1.show(1) ?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36961814
After the new MdiChild opens, change its WindowState property to Normal.  You could use the Shown() event.
0
 
LVL 40
ID: 36961928

Look at all the MDI forms you have used. They do not permit that kind of thing. Its either maximized, normal or minimized.

The only way to have both is to have the non-maximized form be something else than a child.

For a modal form (dialog), it would simply be to open it centered in its owner. Since it needs to be closed before returning to the parent, everything would be fine.

For a non modal form, then things are a little more complicated. You will have to work a bit to toggle the visible property of the small form when the user switch back and forth between the MDI and the small form. You will also have to subscribe to a few events in order for the small form to "follow" the MDI if it is moved around.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36961961
To clarify, all MdiChildren share the same "current" WindowState.  So you can't have some MdiChildren maximized while others are not.  If you want the new MdiChild to open "normal" then you can change it after it opens as I stated...but then all other MdiChildren would also change to the "normal" state as well.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36965326
>To clarify, all MdiChildren share the same "current" WindowState.

Except the Minimized state right?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 36965618
Yesh...  ;)
0
 
LVL 1

Accepted Solution

by:
ict-torquilclark earned 0 total points
ID: 36967235
I think the best option is to go with opening the form as a dialog

Thanks for all the suggestions.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 37205976
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question