ruru evangelista
ruru evangelista

Reputation: 21

how can i convert a mouse position to a location?

I want to create a menu wherein i can hover the titles and the contents will be displayed below but the thing is the panel also dissapear when i mouseleave

Private Sub Label10_MouseLeave(sender As Object, e As EventArgs) Handles Panel9.MouseLeave, Label10.MouseLeave
     Dim x As New Point
     x = MousePosition
     If x = Panel7.Location Then
     Else
         Panel9.BackColor = Color.FromArgb(150, Color.White)
         Panel7.Visible = False
     End If
End Sub

Upvotes: 0

Views: 99

Answers (1)

IOviSpot
IOviSpot

Reputation: 368

To determine whether your mouse is over a specified control, just do:

If myControl.ClientRectangle.Contains(myControl.PointToClient(Control.MousePosition)) Then
    ' Mouse over control
Else
    ' Mouse not over control
End If

Whereas you replace myControl with any control you'd wish to check whether your mouse is over it.

Upvotes: 1

Related Questions