Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 随光标一起显示光标指向坐标_Vb.net - Fatal编程技术网

Vb.net 随光标一起显示光标指向坐标

Vb.net 随光标一起显示光标指向坐标,vb.net,Vb.net,我希望在单击表单中的任何点时,将光标指向坐标显示为有序的pairx,y和光标 有可能这样做吗 我正在使用vb.net windows应用程序。 我试着这样做,但结果都是错误的 您可以使用窗体的鼠标单击事件来执行此操作。让label1是表单中名为frmcursor的label控件,然后您可以编写如下代码: Private Sub frmcursor_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEve

我希望在单击表单中的任何点时,将光标指向坐标显示为有序的pairx,y和光标

有可能这样做吗

我正在使用vb.net windows应用程序。 我试着这样做,但结果都是错误的 您可以使用窗体的鼠标单击事件来执行此操作。让label1是表单中名为frmcursor的label控件,然后您可以编写如下代码:

Private Sub frmcursor_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
    Label1.Left = e.X ' x coordinate of cursor point 
    Label1.Top = e.Y  ' y coordinate of the cursor point
    Label1.Text = "(" & e.X.ToString & "," & e.Y.ToString & ")" 'will display the coordinates as ordered pair
End Sub
更新:

如果希望在光标聚焦表单时显示它,则代码如下:

Private Sub frmcursor_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
    Label1.Left = e.X
    Label1.Top = e.Y
    Label1.Text = "(" & e.X.ToString & "," & e.Y.ToString & ")"
End Sub

您能告诉我们您使用的导致错误的代码吗?如果我们知道你已经尝试了什么,那么给你帮助会更容易。感谢大家的回复,我从下面发布的示例中得到了答案。谢谢。;这实际上是我在寻找的mUVIswas如果下面贴的答案是你想要的,请将其标记为已接受。