通过一个事件、打开的窗体显示在当前窗体的中间?

解决方案 »

  1.   

    直接调整要打开窗体的属性就行了,好像是StartPosition属性,调整为CenterParent,然后将窗体show出来,就OK了
      

  2.   

    简单,首先获取外面长梯的location属性
    然后show新窗体前设置一下StartPosition属性,
    当然根据之前获取的值计算一下
    这样show到中间就行了。
      

  3.   


        private void button1_Click(object sender, EventArgs e)
        {
            Form f = new Form();        // modal dialog        
            f.StartPosition = FormStartPosition.CenterParent;
            f.ShowDialog(this);        // modaless dialog
            f.Show(this);
            f.Left = this.Left + (this.Width - f.Width) / 2;
            f.Top = this.Top + (this.Height - f.Height) / 2;
        }
      

  4.   

    如果是模式窗体Form2 f = new Form2();
    f.StartPosition = FormStartPosition.CenterParent;
    f.ShowDialog(this);如果是非模式窗体,必须自己计算位置
      

  5.   

    将StartPosition属性设为CenterParent 就可以了 不需要那么麻烦的
      

  6.   

    将想要显示在中间的窗体Startposition属性设为CenterParent,然后调用ShowDialog显示模式窗体就行了注意不是用Show()方法