No hay ningún método sobrecargado "OnMouseDown" con 0 parámetros

I am trying to set winform OnMouseDown event to a method I defined called SelectMouseDown.

The method is defined as follows:

method Maker.SelectMouseDown(Sender: Object; e: System.Windows.Forms.MouseEventArgs);

and I am trying to do the following:

OnMouseDown += System.Windows.Forms.MouseEventHandler(@Self.SelectMouseDown);

The compiler throws the following error message: "There is no overloaded method "OnMouseDown" with 0 parameters."

What am I doing wrong? How do you set events during runtime?

Gracias por adelantado,

preguntado el 08 de noviembre de 11 a las 13:11

Estás seguro OnMouseDown es la eventoy no un Método (that invokes the MouseDown evento)? -

1 Respuestas

Te olvidaste new, and the event is named MouseDown as Marc Gravell pointed out:

MouseDown += new System.Windows.Forms.MouseEventHandler(@Self.SelectMouseDown);

I don't know about Delphi, but in C# the compiler can create the delegate automatically:

MouseDown += @Self.SelectMouseDown;

respondido 08 nov., 11:17

Thank you so much. It works after I added the keyword new and changed onmousedown to just mousedown. - ThN

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.