What is the difference between OnLoad
method and Load
event? I am developing WinForm controls.
Should I register to Load
event or override
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
.