Difference between OnLoad method and Load event?

后端 未结 3 1541
星月不相逢
星月不相逢 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条回答
  •  旧时难觅i
    2021-02-19 22:57

    I'd go for overriding OnLoad, so you spare the CPU cycles to invoke the event handler.

    The general pattern is to override a method, if you inherit from a control; otherwise, subscribe to the event.

    But remember to call the base class' OnLoad method, because that's where the Load event invoked.

提交回复
热议问题