【发布时间】:2013-12-02 01:21:22
【问题描述】:
我正在尝试在 button1_Click 之后关闭表单,我尝试在多个位置使用 this.Close(),但它不起作用。我希望单击按钮以打开一个名为 newDB 的新表单。但是当使用 this.Close() 它只会关闭表单而不打开我的新表单。有没有其他方法可以关闭第一个表单并仍然打开 newDB 表单?
private void button1_Click(object sender, EventArgs e)
{
try
{
conn = new SqlCeConnection(@"Data Source=|DataDirectory|\Baseball.sdf; Persist Security Info=False;");
DB newDB = new DB();
newDB.ShowDialog();
this.Close();
}
catch (Exception error)
{
MessageBox.Show("Could not connect to database!\n" + error, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// this.Close();
}
【问题讨论】: