如何让弹出窗体显示在父窗体中间

如题所述

第一子窗体要是非模式的,也就是Show出来而不是ShowDialog 第二要设置子窗体的TopMost属性为True
温馨提示:内容为网友见解,仅供参考
第1个回答  2017-10-17
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

//this.IsMdiContainer = true;
}

private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.StartPosition = FormStartPosition.Manual;
frm.Location = new Point(this.Location.X + this.Width / 2 - frm.Width / 2, this.Location.Y + this.Height / 2 - frm.Height / 2);
frm.Show();
}
}
相似回答