没有合适的资源?快使用搜索试试~ 我知道了~
窗体最小化至系统托盘,并为notifyicon添加右键菜单
4星 · 超过85%的资源 需积分: 37 30 下载量 160 浏览量
2013-03-05
18:14:06
上传
评论
收藏 4KB TXT 举报
温馨提示
试读
5页
本程序教你如何实现窗体最小化后存至系统托盘,并为notifyicon添加右键菜单~
资源推荐
资源详情
资源评论
C#实现窗体最小化时存至系统托盘,并为notifyicon添加右键菜单 .
1.设置窗体属性showintaskbar=false
2.加notifyicon控件notifyicon1,为控件notifyicon1的属性icon添加一个icon图标(该图标为托盘中显示的图标,与窗体的图标不同)。
3.添加窗体最小化事件(首先需要添加事件引用):
//this.sizechanged+=newsystem.eventhandler(this.form1_sizechanged);
//上面一行是主窗体initializecomponent()方法中需要添加的引用
privatevoidform1_sizechanged(objectsender,eventargse)
{
if(this.windowstate==formwindowstate.minimized)
{
this.hide();
this.notifyicon1.visible=true;
}
}
4.添加点击图标事件(首先需要添加事件引用):
privatevoidnotifyicon1_click(objectsender,eventargse)
{
this.visible=true;
this.windowstate=formwindowstate.normal;
this.notifyicon1.visible=false;
}
5.可以给notifyicon添加右键菜单:
主窗体中拖入一个contextmenustrip控件contextmenustrip1,点中控件,在上下文菜单中添加菜单,notifyicon1的contextmenustrip属性选中contextmenu1作为上下文菜单。
1.设置窗体属性showintaskbar=false
2.加notifyicon控件notifyicon1,为控件notifyicon1的属性icon添加一个icon图标(该图标为托盘中显示的图标,与窗体的图标不同)。
3.添加窗体最小化事件(首先需要添加事件引用):
//this.sizechanged+=newsystem.eventhandler(this.form1_sizechanged);
//上面一行是主窗体initializecomponent()方法中需要添加的引用
privatevoidform1_sizechanged(objectsender,eventargse)
{
if(this.windowstate==formwindowstate.minimized)
{
this.hide();
this.notifyicon1.visible=true;
}
}
4.添加点击图标事件(首先需要添加事件引用):
privatevoidnotifyicon1_click(objectsender,eventargse)
{
this.visible=true;
this.windowstate=formwindowstate.normal;
this.notifyicon1.visible=false;
}
5.可以给notifyicon添加右键菜单:
主窗体中拖入一个contextmenustrip控件contextmenustrip1,点中控件,在上下文菜单中添加菜单,notifyicon1的contextmenustrip属性选中contextmenu1作为上下文菜单。
资源评论
- hjlkjlk2013-04-10一般,太简单了
- 陈永宁2014-08-10没能用到自己的工程里~有点遗憾,代码本身没有问题!
小胖seraph
- 粉丝: 6
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功