大师,问一下:
 private void button1_Click_1(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.Owner = this;   //把form2的父控件定位form1
            form2.Location = new Point(30, 30);
            form2.StartPosition = FormStartPosition.Manual;  //弹出位置
            form2.Show();
        }弹出的form2窗口怎么不听使唤呢
确定了location,然后使用form2.StartPosition = FormStartPosition.Manual
弹出的form2窗口怎么不在指定位置呢

解决方案 »

  1.   

    form2.Location = new Point(30, 30);
    form2.StartPosition = FormStartPosition.Manual; //弹出位置
    对调下。
      

  2.   

    form2.Show();
    form2.Location = new Point(30, 30);这样呢?
      

  3.   


    private void button1_Click_1(object sender, EventArgs e)
      {
      Form2 form2 = new Form2();
      form2.Owner = this; //把form2的父控件定位form1
      form2.Location = new Point(30, 30);
      form2.StartPosition = FormStartPosition.Manual; //弹出位置
      form2.ShowDialog();
      }
      

  4.   

    先设置窗体的起始位置为手动的,再设置location 才有用private void button1_Click_1(object sender, EventArgs e)
      {
      Form2 form2 = new Form2();
      form2.Owner = this; //把form2的父控件定位form1
     
      int  x = (sender as Button).PointToScreen(new Point()).X;
      int y = (sender as Button).PointToScreen(new Point()).Y;      form2.StartPosition = FormStartPosition.Manual; //弹出位置
      form2.Location = new Point( x,  y);
      form2.ShowDialog();
      }
      

  5.   


    private void button1_Click_1(object sender, EventArgs e)
      {
          Form2 form2 = new Form2();
         form2.Owner = this; //把form2的父控件定位form1
         if (sender is Button)
         {
             int x = (sender as Button).PointToScreen(new Point()).X;
            int y = (sender as Button).PointToScreen(new Point()).Y;          form2.StartPosition = FormStartPosition.Manual; //弹出位置
            form2.Location = new Point( x, y);
         }
         form2.ShowDialog();
    }
      
      

  6.   

    form2.StartPosition = FormStartPosition.Manual; 
    form2.Left =30;
    form2.Top =30;
    form2.Show();
      

  7.   

    在窗体布局里找到StartPosition  属性换成CenterScreen
      

  8.   

    我觉得Show了之后再设置位置应该是可以的
      

  9.   

    这样不行 必须得再 Form2 的Load事件里面 定义 Location  你可以这样  写一个 Class1 类  用于保存 在 form1 给 form2 中定义的 location比如 
     class1 中的 代码    
         private Point pointLocation;
         public Point PointLocation;
        {
          get{return pointLocation;}set{pointLocation=value;}
          } 
     form1 中的 代码
       Class1 c1=eew Class1();
         ....
        cl=new Point(30, 30);
        ....from2 中的代码
      Class1 c1=eew Class1();
       ......
      然后 在 form2 中的 Load 事件中  代码
      
       this.Location =c1.pointLocation;就 行了 !