Hi,
I want to know if I'm doing something wrong. I'm inheriting frmChild
from frmBase in Project1. frmBase is referring to its MdiParent in a function
call from Form_Resize event. When I try to open the designer for the frmChild
it throws an exception for this, saying "Object reference not set to an
instance of an object."

Why is this happening. Does that mean I cannot use any runtime
instanciation in a base form? Or do I have to turn something off? Why is the
code executing in the designer. If I give a message box in the base form, it
pops up when I am loading the Child form!!!!!

Any help is appreciated..

Thanx,
Debi

Re: Help!!! Visual Inheritance...... by Sijin

Sijin
Tue Oct 19 06:03:59 CDT 2004

In your form_resize event just add a check to see if form.MdiParent is
null and if so then do nothing.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Debi wrote:
> Hi,
> I want to know if I'm doing something wrong. I'm inheriting frmChild
> from frmBase in Project1. frmBase is referring to its MdiParent in a function
> call from Form_Resize event. When I try to open the designer for the frmChild
> it throws an exception for this, saying "Object reference not set to an
> instance of an object."
>
> Why is this happening. Does that mean I cannot use any runtime
> instanciation in a base form? Or do I have to turn something off? Why is the
> code executing in the designer. If I give a message box in the base form, it
> pops up when I am loading the Child form!!!!!
>
> Any help is appreciated..
>
> Thanx,
> Debi

RE: Help!!! Visual Inheritance...... by JLeBert

JLeBert
Tue Oct 19 10:09:02 CDT 2004

The problem is that a number of events fire when a form is in design mode. If
you have code in your event handler, it will probably mess things up. The
solution is to check the DesignMode property. If it is True then skip your
code.

It is "correct" for the events to fire in the designer because you might
have custom controls or forms that need special logic such as rearranging
child controls when the custom control/form is resized.

NOTE the DesignMode property is set after the code in the constructor runs.
If you have code in the constructor or that is called in the constructor,
then DesignMode will be False even though you really might be in DesignMode.