all groups > vb.net controls > december 2006 >
You're in the

vb.net controls

group:

LinkLabel Click, LinkClicked events


LinkLabel Click, LinkClicked events Fred
12/12/2006 12:00:00 AM
vb.net controls: I want to use the LinkLabel.Click event (not the LinkLabel.LinkClicked) but
I need to know if the mouse is pointing to a link and if so which link.

My linkLabel control will have numerous links in it and I want to show a
popup menu when right clicking anywhere on the control even if the mouse is
not pointing to a link hence I want to use the click event.

The problem is that before loading the menu I need to know if the mouse is
pointing to a link and if so which one. The only way I seem to be able to
get the link data is through the LinkClicked event but that occurs after the
Click event so I don't have that information when I am trying to load my
menu.

Can anyone tell me how I can check if the mouse is pointing to a link during
a LinkLabel.Click event.

The control underlines each link when the mouse hovers over it. Is there
some event that occurs when this happens?

Thanks for any help
Fred

Re: LinkLabel Click, LinkClicked events HKSHK
1/1/2007 10:30:46 AM
Hi, Fred!

The MouseUp event is what you are looking for, because it comes Before
the LinkClicked event. So you catch the mouse button pressed in MouseUp
and process it in LinkClicked as in the example code below.

Best Regards and Happy New Year,

HKSHK

'BEGIN

Dim RightClick As Boolean

Private Sub LinkLabel1_MouseUp(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles LinkLabel1.MouseUp

RightClick = (e.Button = MouseButtons.Right)
End Sub


Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles LinkLabel1.LinkClicked

If RightClick Then
Debug.WriteLine("Right click")
Else
Debug.WriteLine("Other click")
End If

End Sub

'END



[quoted text, click to view]
AddThis Social Bookmark Button