Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form position in IDE
Message
From
08/11/2005 11:32:26
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01065393
Message ID:
01066468
Views:
19
>thanks Bonnie, no DoDefault() here then ! <g>

LOL! But, if you want to change the normal behavior, you can. Typically when the IDE creates an EventHandler for you, it's created as private. If you change that in your base class to protected virtual, then you could override it in your derived class and you wouldn't even need a delegate in the derived class.

In other words, the normal behavior would be this:
// Base class:
this.Load += new System.EventHandler(this.MyBaseForm_Load);
...
private void MyBaseForm_Load(object sender, System.EventArgs e)
{
	MessageBox.Show("Base Load");
}

// Derived class:
this.Load += new System.EventHandler(this.Form1_Load);
...
private void Form1_Load(object sender, System.EventArgs e)
{
	MessageBox.Show("Derived Load");
}
To alter the normal behavior, you could do this:
// Base class:
this.Load += new System.EventHandler(this.MyBaseForm_Load);
...
protected virtual void MyBaseForm_Load(object sender, System.EventArgs e)
{
	MessageBox.Show("Base Load");
}

// Derived class (note that I've removed the delegate):
protected override void MyBaseForm_Load(object sender, System.EventArgs e)
{
	MessageBox.Show("Derived Load");
	base.MyBaseForm_Load (sender, e);

}
So, it's still as flexible as you need it to be.

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform