Label OnClick

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I add an OnClick event to a Label control? Or do I have to derive from
Control and do it all from scratch?
I had a look at the OpenCF LinkLabel but I don't think I need all that extra
functionality.

Adam
 
The Click event for the Label isn't implemented in the current version. I
would suggest looking at the OpenNETCF LinkLabelEx control source and then
adapting your own control from there, or if you search around on the web I'm
sure someone has created a simple Label control replacement.
 
Hi Amp,

If you like its possible for you to create a custom class of type
control and insert these codes

Protected Overrides Sub OnMouseDown(e As MouseEventArgs) - or in OnMouseUp()
Me.Capture = Me.ClientRectangle.Contains(e.X, e.Y)
If Me.Capture Then
Method_Click()
End If
End Sub

Another option, you can try it in your own Parent form by overriding the
mousedown or mouseup event.

Protected Overrides Sub OnMouseUp(ByVal e As
System.Windows.Forms.MouseEventArgs)
Dim rec As Rectangle
rec = New Rectangle(Label1.Left, Label1.Top, Label1.Right,
Label1.Bottom)
If rec.Contains(e.Y, e.Y) Then
Method_Click()
End If
End Sub
 
Back
Top