vb.net - 如何将鼠标位置转换为位置?
问题描述
我想创建一个菜单,我可以将标题悬停在其中,内容将显示在下方,但问题是当我鼠标离开时面板也会消失
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
解决方案
要确定您的鼠标是否在指定控件上,只需执行以下操作:
If myControl.ClientRectangle.Contains(myControl.PointToClient(Control.MousePosition)) Then
' Mouse over control
Else
' Mouse not over control
End If
而您替换myControl
为您希望检查鼠标是否在它上面的任何控件。
推荐阅读
- python - 创建一个包含 2 个不相等列表的字典
- javascript - 组件输入中的错误
- c# - xamarin UITest 与 dotnet 核心不兼容?
- javascript - 使用 javascript 创建路段
- php - 如果数据库中没有行,则返回带有环境变量的模型
- video - 没有广告的 YouTube 嵌入不再与 adblocker 一起工作
- javascript - 发送以响应状态循环问题的对象
- flutter - 如何在 Flutter 的 Preferences 中检索 RadioPreference、CheckPreference 值
- python - 关于逻辑回归和线性回归的问题
- c# - IAuthorizationFilter ASP.Net Core 3 中的依赖注入