vb 2010在面板中找不到鼠标位置的表格 [英] vb 2010 find mouse position in the panel not the form

查看:119
本文介绍了vb 2010在面板中找不到鼠标位置的表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题的标题问了所有这些,我想知道我的鼠标在面板中的位置,而不是例如

我知道了

well the title of the this question asks it all, I wanna know my mouse location in the panel not the form like eg

I get this

If (Windows.Forms.Cursor.Position.X < 30) Then
        Me.Close()
    ElseIf (Windows.Forms.Cursor.Position.X > 30) Then
        Me.WindowState = FormWindowState.Minimized
    End If



但是我想要这个



But I want this

If ( Panel.MousePosition.X  < 30) Then
        Me.Close()
    ElseIf ( Panel.MousePosition.X  > 30) Then
        Me.WindowState = FormWindowState.Minimized
    End If



但是代码总是想更改



but the code always want to change

Panel.MousePosition.X 



回到



back to

Windows.Forms.Cursor.Position.X



并且代码不起作用,只是找到整个表单中的光标位置,而不是我放下的面板



and the code doesn''t work it just find the cursors location in the whole form not that panel I put down

推荐答案

使用方法:
Using:
If ( Panel.MousePosition.X  < 30) Then


您应该得到警告:通过实例访问共享成员;合格表达式将不被评估[ ^ ]

使用事件:


you should get a warning: Access of shared member through an instance; qualifying expression will not be evaluated[^]

Use an event:

Private Sub Panel1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
    Me.Text = "X: " & e.X.ToString & " Y: " & e.Y.ToString
End Sub


这篇关于vb 2010在面板中找不到鼠标位置的表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆