hugas

How to make that when user clicks on label, another form would open (just like the button, but the same code doesn't work on label)


Re: Visual Basic Express Edition clicking labels

Fase

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
form.show
End Sub




Re: Visual Basic Express Edition clicking labels

hugas

that doesn't work because Label1.MouseEnter event is activated (for changing color), so it opens form without clicking the label, and i want it to open, only when i click on it.




Re: Visual Basic Express Edition clicking labels

Fase

Chance to Handles Label1.MouseDown or MouseUP

I don't quite understand what the problem is.




Re: Visual Basic Express Edition clicking labels

jo0ls

Hugas, Fase said to handle the click event, not the mouse enter event. If you need to handle both events then do so...

Public Class Form1

Shared rand As New Random

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Dim f As New Form
f.ShowDialog()
End Sub

Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseEnter
Label1.BackColor = Color.FromArgb(rand.Next(Integer.MinValue, Integer.MaxValue))
End Sub

End Class





Re: Visual Basic Express Edition clicking labels

spotty

Would a linklabel control be more suitable





Re: Visual Basic Express Edition clicking labels

hugas



 jo0ls wrote:
Hugas, Fase said to handle the click event, not the mouse enter event. If you need to handle both events then do so...

Public Class Form1

Shared rand As New Random

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Dim f As New Form
f.ShowDialog()
End Sub

Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseEnter
Label1.BackColor = Color.FromArgb(rand.Next(Integer.MinValue, Integer.MaxValue))
End Sub

End Class





thanks a lot.




Re: Visual Basic Express Edition clicking labels

hugas

spotty wrote:

Would a linklabel control be more suitable



what it is