|
-
Mar 29th, 2006, 01:59 PM
#1
Thread Starter
Member
Mouse Buttons and Labels
I have a two dimensional array of labels with a common click event handler.
I have not yet discovered the magic required to determine which mouse button was clicked in the handler. There is no lblArray(I,J).Buttons property.
So my question is: How do I determine if th eright mouse button was clicked? I have tried:
VB Code:
if lblArray(I, J).MouseButtons and MouseButtons.Right <> 0 then
...
end if
to no avail. In fact, lblArray(I,J).MouseButtons is always zero.
(I have a way to determine the I and J from the mouse click.)
RussCanada
Ontario, Canada
-
Mar 29th, 2006, 02:23 PM
#2
Re: Mouse Buttons and Labels
if you are handling the mouse clicks in the mousedown (or mousemove ??) event then the button state is available in e.button
i.e.
VB Code:
Private Sub TitleBar_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TitleBar.MouseDown
If e.Button = MouseButtons.Right Then
End If
End Sub
HTH
kevin
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Mar 29th, 2006, 04:45 PM
#3
Thread Starter
Member
Re: Mouse Buttons and Labels
Kevin, I tried your suggestion but couldn't get it to work. I was not able to set up the proper handler for the MouseDown event. In your case, you knew the specific design-time object from which the event occurs, but in my situation I don't know until run-time. I presume there is something I don't know. (What else is new???)
RussCanada
Ontario
-
Mar 29th, 2006, 05:22 PM
#4
Re: Mouse Buttons and Labels
The Control.MouseButtons property is Shared so you shouldn't be calling it on an instance anyway. It indicates which mouse buttons are depressed at that moment. To raise a Click event you must depress and release a mouse button so no buttons will be depressed when the Click event is raised.
You should create your MouseDown and/or Click event handlers but omit the Handles clause. Once you've created your array of Labels you can use nested For loops to traverse the entire matrix and use the AddHandler statement to attach the event handlers to the appropriate events.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|