views:

29

answers:

2

I made a custom button by inheriting the Button class. When I double click the custom button in Designer, it makes the event handling function for MyButton.Click:

Private Sub MyButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyButton1.Click

    End Sub

How can I make it so that when you double click, it makes the event handling function for another event? For example, MyButton.KeyUp:

Private Sub MyButton1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyButton1.KeyUp

    End Sub

Hopefully, someone can help me with this.

+2  A: 

Have you tried the DefaultEvent attribute?

Example from MSDN:

<DefaultEvent("CollectionChanged")> _ 
Public Class MyCollection
    Inherits BaseCollection

    Public Event CollectionChanged (ByVal sender As Object, _
        ByVal e As CollectionChangeEventArgs)

    ' Insert additional code.
End Class 'MyCollection
Paul Williams
+2  A: 

use DefaultEventAttribute:

<DefaultEvent("KeyUp")> Public Class MyButton
max
Thanks, I'll try it in a bit and let you know if it worked.
Arjan
@Arjan: Without trying it, I know it works. I know this because I've used it countless times.
Alex Essilfie
It worked very well, thanks!
Arjan