private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.Hide();
} private void menuItem8_Click(object sender, System.EventArgs e)
{
this.Dispose();
}我想做一个类似sqlserver服务控制器的小东西,遇到了点小问题.我希望点击x的时候不要关闭窗口,真正的关闭放在系统托盘的右键菜单里,事实上我上面的程序已经做到这一点.但是奇怪的问题来了,windows关机的时候却无法把我的程序关闭,导致无法关机.请教一下各位老大,有没有什么办法能两全其美.
{
e.Cancel = true;
this.Hide();
} private void menuItem8_Click(object sender, System.EventArgs e)
{
this.Dispose();
}我想做一个类似sqlserver服务控制器的小东西,遇到了点小问题.我希望点击x的时候不要关闭窗口,真正的关闭放在系统托盘的右键菜单里,事实上我上面的程序已经做到这一点.但是奇怪的问题来了,windows关机的时候却无法把我的程序关闭,导致无法关机.请教一下各位老大,有没有什么办法能两全其美.
解决方案 »
- 求轻量级免费数据库
- C#调试时运行结果一闪就没了是怎么回事
- c#操作摄像头中常量定义问题
- 如何获取当前grid中显示的内容?
- GDI+ 一般请错误(win form)
- 如何在dategrid中隐藏部分记录?
- 在VB.NET社区挂于首页3天,连续换气4次无人能回帖的高分问题
- 请大家帮忙!急!50分
- 用Grid++Report 4.5做报表时,“Report.Parameters["YSJE"]”引发了“System.Runtime.InteropServices.COMException”类型的异常?
- 如何在C#中实现两个程序的通信?
- C#里怎么对一个小数4舍五入啊?谢谢
- SmtpMail类对象为什么不能用Send()方法?
private void menuItem8_Click(object sender, System.EventArgs e)
{
closeMe=true;
Application.Exit();
}private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if(!closeMe)e.Cancel = true;
}
{
Application.Exit();
}就可以了
{
e.Cancel = !closeMe;
if (!closeMe) this.Hide();
} private void menuItem8_Click(object sender, System.EventArgs e)
{
closeMe = true;
this.Close();
}
哈哈,好像是这样子的,只有手动去关掉应用程序才能关机
不知道msn是怎么实现的
最关键的是还是不能关机。请问一下windows关闭应用程序的时候是不是也要从Form1_Closing执行????
// 这样才能实现系统关闭的时候自动关闭本程序。
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (this.WindowState != FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Minimized;
e.Cancel = true;
}
else e.Cancel = false;
}