Visual Studio: replace default doubleclick-event

310 views Asked by At

I am aware of DefaultEventAttribute but I am still a bit clueless of how to implement it correctly.

I have made a simple control class that inherits from NumericUpDown:

public class NumericControl : System.Windows.Forms.NumericUpDown

I want to use it in my project instead of a default NumericUpDown control, and I want to replace a default doubleclick-generated event in visual studio. By default it's:

private void numericUpDown1_ValueChanged_1(object sender, EventArgs e)

And I want it to be

private void numericUpDown1_KeyPress(object sender, KeyPressEventArgs e)

Thanks in advance.

Edit: No, no, I have seen this question already. But I just want to simply replace one event by another (and both of them are already built-in in the control). I don't want to assign it to some custom event. My issue is much simpler but I still struggled with it.

1

There are 1 answers

2
ASh On BEST ANSWER

if you just add DefaultEvent attribute to your control class with another event name, it should work fine (rebuild projects before check after adding attribute)

[DefaultEvent("KeyPress")]
public class NumericControl : System.Windows.Forms.NumericUpDown