1
new System.Windows.Forms.MouseEventHandler(this.eventFunction)

the above sends an 'object sender' and 'MouseEventArgs e' to my event function. I need to send another object with it, but if I use:

System.Windows.Forms.MouseEventHandler(this.eventFunction(object, MouseEventArgs, objectINeed));

It doesn't work. It just says there is an invalid argument. Even if I blatantly send it an object, MouseEventArgs, object.

Can anyone provide any insight?

4

2 回答 2

0

没有原因对象发送者应该已经拥有您需要传递给事件的信息。事件附加到对象。

您可以创建一个可以从事件中调用的方法,以检索您需要的对象或数据。

或者您可能使您需要引用的对象的范围足够高,以至于它已经可用于事件。

于 2012-11-06T00:59:30.473 回答
0

您可以执行以下操作:

new System.Windows.Forms.MouseEventHandler((s, e) => this.eventFunction(objectINeed, e));

但是你为什么需要那个?

于 2012-11-06T01:48:57.327 回答