Difference between OnLoad method and Load event?

后端 未结 3 1531
星月不相逢
星月不相逢 2021-02-19 22:34

What is the difference between OnLoad method and Load event? I am developing WinForm controls. Should I register to Load event or override

3条回答
  •  后悔当初
    2021-02-19 22:51

    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.

提交回复
热议问题