Leon Lai Kan
Posts: 200
Joined: 2018-12-20
|
red
Hello,
I always wondered what we can do with the sender parameter of a click event.
So, it was a nice surprise when I found a simple example on the web.
Here is the code:
Private Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Button1.Click, Button2.Click
Dim s As String
If sender Is Button1 Then
s = "button1"
ElseIf sender Is Button2 Then
s = "button2"
End If
MessageBox.Show("You pressed: " & s)
End Sub
I created 2 buttons in the Ribbon: Button1, and Button2
Then I copied the above code in AddInModule.vb.
As expected, it will not work.
I get this Error Message:
Method 'Private Sub Button_Click(sender As Object, e As System.EventArgs)'
cannot handle event
'Public Event OnClick(sender As Object, control As AddinExpress.MSO.IRibbonControl, pressed As Boolean)'
because they do not have a compatible signature.
Can you help me make the sample work (if this is possible)?
Thanks
Leon
added:
I modified the 1st line to:
Private Sub Button_OnClick(ByVal sender As System.Object, _
ByVal control As AddinExpress.MSO.IRibbonControl, _
ByVal pressed As System.Boolean) Handles Button1X.OnClick, Button2X.OnClick
This time no build error, but does not work
red |
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
Hello Leon,
Thank you for letting us know!
Andrei Smolin
Add-in Express Team Leader |
|