Help!!! Visual Inheritance......

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
Back
Top