设置表单位置c#

时间:2014-06-03 13:36:31

标签: c# forms location

我想知道如何设置我的表格位置。我试图做以下事情:

this.Location = Point; 

或:

Form2.Left = Point.X;
Form2.Top = Point.Y;
Form2.ShowDialog();

这不起作用。我做错了什么?

6 个答案:

答案 0 :(得分:10)

   private void button1_Click(object sender, EventArgs e)
    {
        Form form2 = new Form();
        form2.StartPosition = FormStartPosition.Manual;
        form2.Left = 500;
        form2.Top = 500;
        form2.ShowDialog();
    }

答案 1 :(得分:0)

试试这个:

private void Form_Load(object sender, EventArgs e)
{
    this.SetDesktopLocation(x, y);
}

答案 2 :(得分:0)

$scope.scrollxx = function( ) {
    console.log("scrolltoaaaa");
}

答案 3 :(得分:0)

您的第一种方法仍然有效。

this.Location = new Point(/*XPosition*/, /*YPosition*/);

答案 4 :(得分:0)

要以编程方式设置位置,应将 StartPosition 设置为 FormStartPosition.Manual ,如下所示:

Form myform = new Form()
{
     Size = new Size(200,200),
     StartPosition = FormStartPosition.Manual,
     Location = new Point(10,10) // or Cursor.Position if you want to set it to cursor position
}

答案 5 :(得分:0)

您可以这样设置:

form1.Location = new Point(4, 370);