private void Form1_Load(object sender, EventArgs e)
{
if (MessageBox.Show("是否打开", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.OK)
{
//new 出你要打开的新窗体
}else{
this.close();//或者
application.exit();
}
}
首先,你点击的只有MessageBoxButtons.Yes或者MessageBoxButtons.No,
所有不要用OK,
private void Form1_Load(object sender, EventArgs e)
{
if (MessageBox.Show("是否打开", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
{
Application.Exit();
}
}
private void Form1_Load(object sender, EventArgs e)
{
if (MessageBox.Show("是否打开", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
{
Form1.Close();
}
}