What is the difference between OnLoad method and Load event? I am developing WinForm controls.
Should I register to Load event or override the OnLoad method? What are the advantages and the disadvantages of each one?
OnLoad method is the one that raises Load event. It's a standard pattern in framework classes, and a generally recommended one - for any event Foo, you have a virtual protected method OnFoo which raises that event; and no other method of the class raises the event directly, but always calls OnFoo.
If you need to handle the event on this, it's usually both easier and faster to override OnFoo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With