先
public Form1()
{
InitializeComponent();
this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
// }
后
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
if (MessageBox.Show("将要关闭程序,是否继续?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) {
e.Cancel = false;
}
else
{
e.Cancel = true;
}
}
然后
有个按钮事件
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
初次运行,按按钮是会提示关闭提示的.
但是我的程序里还有一个最小化到托盘(同时隐藏了系统状态栏显示,只在托盘显示)
当最小化到托盘,再显示时,按按钮就直接退出,没有提示.
求助原因.
public Form1()
{
InitializeComponent();
this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
// }
后
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
if (MessageBox.Show("将要关闭程序,是否继续?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) {
e.Cancel = false;
}
else
{
e.Cancel = true;
}
}
然后
有个按钮事件
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
初次运行,按按钮是会提示关闭提示的.
但是我的程序里还有一个最小化到托盘(同时隐藏了系统状态栏显示,只在托盘显示)
当最小化到托盘,再显示时,按按钮就直接退出,没有提示.
求助原因.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货