Nerseus
Danner
I'm wondering if anyone's seen any reason why overriding an event on a form is better/worse than adding an event handler. Not counting the overhead of calling the base class's event and not counting the slight overhead of adding an event handler...
For example, to use the Form_Load event, you can use:
or you could use:
At my company we've always used the event handler method, mostly because it's easier but somewhat out of ignorance (we had a lot of developers coding who didn't know you could use the override OnLoad).
With hiring some new people I'm in the process of reviewing our coding standards document and wanted to get some outside opinions. Maybe Microsoft has recommended a certain method? Maybe it's like variable naming - just pick a standard and use it consistently? Or maybe there's something we're missing...?
Thanks all!
-Nerseus
For example, to use the Form_Load event, you can use:
C#:
// In InitializeComponent
this.Load += new System.EventHandler(this.Form1_Load);
// Farther down, the actual function:
private void Form1_Load(object sender, System.EventArgs e)
{
// Do something here
}
or you could use:
C#:
protected override void OnLoad(System.EventArgs e)
{
// Do something here
// Finally, call base class
base.OnLoad(e);
}
At my company we've always used the event handler method, mostly because it's easier but somewhat out of ignorance (we had a lot of developers coding who didn't know you could use the override OnLoad).
With hiring some new people I'm in the process of reviewing our coding standards document and wanted to get some outside opinions. Maybe Microsoft has recommended a certain method? Maybe it's like variable naming - just pick a standard and use it consistently? Or maybe there's something we're missing...?
Thanks all!
-Nerseus