我想创建一个菜单,我可以将标题悬停在菜单上,内容将显示在下面,但是当我离开鼠标时,面板也消失了
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
答案 0 :(得分:1)
要确定鼠标是否位于指定控件上,只需执行以下操作:
If myControl.ClientRectangle.Contains(myControl.PointToClient(Control.MousePosition)) Then
' Mouse over control
Else
' Mouse not over control
End If
将myControl
替换为要检查鼠标是否在其上的任何控件。