Inherited Forms

  • Thread starter Thread starter Olivier Sauterel
  • Start date Start date
O

Olivier Sauterel

Hi all,
Anyone can tell me if the derived forms need to call the constructor of the
ancestor Form ?
Also it's needed to call InitializeComponent() from Ancestor form or not ?

Sample:
public Class AncestorForm: System.Windows.Forms.Form
{
Public AncestorForm() //:base() needed or not ?
{
InitializeComponent();
}
}

public Class DerivedForm: AncestorForm
{
Public DerivedForm(): base() //:base() needed of not ?
{
InitializeComponent();
}
}

Tanks for your help
 
Hi Olivier,

The default constructor of the parent object will automatically be called,
however if the parent has a parameterised constructor that you want called
when the derived object is created you will need to explicitly call it.

Regards

James Thresher
 
Back
Top