Nerseus
Danner
Im wondering if anyones 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 classs 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 weve always used the event handler method, mostly because its easier but somewhat out of ignorance (we had a lot of developers coding who didnt know you could use the override OnLoad).
With hiring some new people Im in the process of reviewing our coding standards document and wanted to get some outside opinions. Maybe Microsoft has recommended a certain method? Maybe its like variable naming - just pick a standard and use it consistently? Or maybe theres something were 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 weve always used the event handler method, mostly because its easier but somewhat out of ignorance (we had a lot of developers coding who didnt know you could use the override OnLoad).
With hiring some new people Im in the process of reviewing our coding standards document and wanted to get some outside opinions. Maybe Microsoft has recommended a certain method? Maybe its like variable naming - just pick a standard and use it consistently? Or maybe theres something were missing...?
Thanks all!
-Nerseus