Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15463

[RESOLVED] Problem with e.Button.

$
0
0
Hi,
I'm trying to detect a right click on any one of at least 150 labels, the labels are application generated.
The generating code includes an AddHandler:
Code:

  AddHandler lbl.Click, AddressOf LabClik
Running the code with a breakpoint set at the first instruction of the LabClik subroutine:
Code:

Private Sub LabClik(sender As Object, e As System.EventArgs)

        If boom Then Exit Sub

I can see the detail of e. which includes:
Quote:

+ e {X = 22 Y = 24 Button = Left {1048576}} System.EventArgs {System.Windows.Forms.MouseEventArgs}
However, when I include the instruction:
Code:

If e.Button = Windows.Forms.MouseButtons.Right Then
Intellisense complains about "e.Button", saying that it's not a member of EventArgs, despite the fact that I can see "e.Button", and it's value in the Watch1 window.

In the past I've written a Subroutine using...
Code:

Private Sub Pict_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
... which allowed me to read the "e.Button", so I tried:
Code:

Private Sub LabClik(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
(With and without the two ByVal's)

This did allow "e.Button", but... Now... Intellisense complains:
Quote:

Option Strict On does not allow narrowing in implicit type conversions between method 'Private Sub LabClik(sender As Object, e As MouseEventArgs)' and delegate 'Delegate Sub EventHandler(sender As Object, e As EventArgs)'.
Changing 'Private Sub' to 'Public Sub' only changed the complaint from 'Private Sub' to 'Public Sub'.
As I'm reluctant to switch Option Strict to Off I can't find where to go from here.


Poppa.

Viewing all articles
Browse latest Browse all 15463

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>