Click here to Skip to main content
16,018,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
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
Updated 24-Mar-11 5:19am
v2

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
 
Share this answer
 
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.
 
Share this answer
 

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