public static ConDbForm GetInstance(ScriptForm parent) { //判断是否存在该窗体,或时候该字窗体是否被释放过,如果不存在该窗体,则 new 一个新窗体 if (_instance == null || _instance.IsDisposed) { _instance = new ConDbForm(parent); } return(_instance); }
private void 连接ToolStripMenuItem1_Click(object sender, EventArgs e) { conDbForm = ConDbForm.GetInstance(this); conDbForm.FormBorderStyle = FormBorderStyle.FixedDialog; conDbForm.TopLevel = true; conDbForm.ControlBox = true; conDbForm.Dock = DockStyle.Fill; conDbForm.StartPosition = FormStartPosition.Manual; var left = Parent.Parent.Width / 2 + Parent.Parent.Left - conDbForm.Width / 2; var right = Parent.Parent.Height / 2 + Parent.Parent.Top - conDbForm.Height / 2; conDbForm.Location = new Point(left, right); conDbForm.ShowDialog(); }