It is possible to pass data to EventArgs without creating derived class?

前端 未结 3 1103
梦如初夏
梦如初夏 2021-02-19 07:27

I am a bit confused. I know I can create class derived from EventArgs in order to have custom event data. But can I employ the base class EventArgs somehow? Like the mouse butto

3条回答
  •  执笔经年
    2021-02-19 08:30

    Nope. The EventArgs base class is just a way to allow for some standard event delegate types. Ultimately, to pass data to a handler, you'll need to subclass EventArgs. You could use the sender arg instead, but that should really be the object that fired the event.

提交回复
热议问题