Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/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
C# 设置鼠标的位置_C#_Position_Cursor - Fatal编程技术网

C# 设置鼠标的位置

C# 设置鼠标的位置,c#,position,cursor,C#,Position,Cursor,我无法纠正我的错误:/ if(Cursor.Position=新点(x,y) 我在x,y上有一个错误,我想更改为50,99,例如首先,您应该触发鼠标单击事件。它非常简单: this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseClick); 然后你应该处理事件。假设你想要的位置是(x,y)=(100100): if(Cursor.Position=new Point(x,y)在if中,您需要使

我无法纠正我的错误:/

if(Cursor.Position=新点(x,y)


我在
x,y
上有一个错误,我想更改为
50,99
,例如

首先,您应该触发鼠标单击事件。它非常简单:

this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseClick);
然后你应该处理事件。假设你想要的位置是(x,y)=(100100):


if(Cursor.Position=new Point(x,y)
if
中,您需要使用
=
。若要设置它,请根据需要正确设置x和y,当然,如果没有
if
。您忘了完成”),如果(Cursor.Position=new Point(x,y)),则必须在点(x,y)之后再添加一个点若要关闭if条件。这只是关于打字错误,您应该删除该问题。.我单击该位置,其效果不佳,命中单个点的机会非常小!请尝试:
if(新矩形(211,480,6,6).Contains(Cursor.Position))…
首先,你能告诉我你到底想做什么吗?很抱歉耽搁了。我想在我们单击​​表格,我想有一条信息出现,谢谢。你如何确保你点击了某个位置?你知道如何处理c#中的事件吗?
private void Form1_MouseClick(object sender, MouseEventArgs e)
    {
        int xDesired = 100;
        int yDesired = 100;
        if (e.X == xDesired && e.Y == yDesired)
            MessageBox.Show("Certain point clicked.");
    }