Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Everyone,

Im Getting a Peculiar Problem here My Menu Form is the MDI Container here Im Opening a Form in Maximized Mode and on That Form a Button Click has Open another Maximized form but here im Getting a Error Thrown as Object Reference not set and its Taking me to a Dilogue What May Be the Issue Im Pasting here how im Calling the New Form.

Form frm = new Form();
frm.MdiParent = MdiParent;
frm.WindowState = FormWindowState.Normal;
frm.WindowState = FormWindowState.Maximized;

Thanks and Regards
Madhukumar N
Updated 24-Jun-22 3:46am

This is what I did. I created a method at the just below the the mdi form constructor like below:
public MainRibbonForm()

private void SetMaximizedChildFormsToNormal()
    foreach (Form form in this.MdiChildren)
        form.WindowState = FormWindowState.Normal;

Then where the form form is being called I call the above method before. Like below:
AreaOfLawViews.AreaOfLawMetroForm appForm = new AreaOfLawViews.AreaOfLawMetroForm()
    MdiParent = this,
    StartPosition = FormStartPosition.CenterScreen,
    WindowState = FormWindowState.Maximized

So, the already opened form is set to Normal before the new form is opened and maximized. It is working for me already.

I hope this helps.
Share this answer
Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don't. Please see:[^],
How to Create MDI Parent Window in WPF?[^].

I can explain what to do instead. Please see my past answers:
How to Create MDI Parent Window in WPF? [Solution 2],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last childform minimized[^].

Share this answer
Madhukumar N 29-May-13 0:53am    
Actually My Application is not in WPF its simple Windows application can u help out?
Sergey Alexandrovich Kryukov 29-May-13 0:58am    
I already did. You only need to write my answers, not just titles. They are not really related to WPF.

There are a number of alternatives. It could be TabControl, some accordion-like panels, or simply hiding/showing panels; you can even make a docking UI much like Visual Studio. The simplest solution which also is very convenient for the users is TabControl:


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900