Click here to Skip to main content
11,502,201 members (66,320 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
When I try to do a check to see that the active form is an MDIContainer, I keep getting an null reference error. Object reference not set to an instance of an object.

This is what I try:

if(form.ActiveForm.IsMdiContainer)
Also some times a child form will open outside of the MDI container even though I set the MdiParent of that child form to the MDIcontainer.

Is MDIContainer good to use even or is there something better I should be looking at?

Any help would be greatly appreciated
Posted 24-Mar-11 4:40am
Edited 24-Mar-11 5:19am
Henry Minute224.4K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Look at the form properties and find all of them containing sub-string "MDI", it will explain how to use MDI. MDIContainer is something you need to define.

I have a better advice:

But do yourself a favor, listen to my good friendly advice: don't do MDI!
There are not so many UI designs that are so inconvenient and cumbersome! Everyone I know (and I know very many computer people, not just developers) hate such user experience and well agree with me. You cannot find any serious company or UI developer using such design.

Instead, use tabbed UI, or dockable (or combined), or controlled by tree/list view TOC-page style, or folding panels or something like that.

—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

When you run in debug mode and the exception occurs, hover your mouse pointer over each word in your statement.

The tooltip you should see will tell you which is null. My guess would be ActiveForm but only you can determine this for certain.

Once you have discovered the culprit you will need to think about the reason(s) that might be.
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 24 Mar 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100