如何通过任务栏中的通知图标打开关闭的表单?
目前我正在用 C# 开发一个 Windows 窗体应用程序,它有多种窗体。
我正在运行一个后台表单,它操作 notificationicon 属性,允许图标出现在任务栏中。
当我启动程序时,它将启动一个登录表单,之后登录将进入主表单。关闭 mainForm 后,应用程序尚未关闭,在本例中其工作方式类似于 Windows Live Messenger。
如何使我的程序在主窗体后通过双击它将重新显示窗体? (就像 MSN 的工作方式一样。)
或者,当我按标题栏中的 X 按钮时关闭整个应用程序,这对我来说是更好的解决方案吗?这给我带来了另一个问题,因为当我关闭主窗体以外的其他窗体时,我似乎无法退出应用程序。
Currently I am developing a windows form application in c# that has several forms.
I am running a background form that operates the notifyicon property that allows the icon to appear in the taskbar.
When I launch the program, it will launch a loginForm, after which logging in it will go into a mainForm. After closing the mainForm, the application does not close yet, which in this case works like Windows Live Messenger.
How do I make my program in a way that after I the mainForm, through double clicking it will bring the form back up? (Like how MSN works.)
Or is it a better solution for me to close the whole application when I press the X button in the title bar. Which brings up another problem for me as I cant seem to exit the application when I close other forms other than the main form.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将表单的
Visible
属性设置为true
/false
即可。或者您可以调用Show()
/Hide()
。Just set the
Visible
property of the form totrue
/false
. Or you could callShow()
/Hide()
.也许您的主窗体上有 NotifyIcon。订阅该控件的
DoubleClick
事件并在处理程序中更改主窗体的状态:Probably you have NotifyIcon on your main form. Subscribe on the
DoubleClick
event of this control and change state of your main form in the handler: