C# winForm实现的气泡提示窗口功能示例
来源:本站原创|时间:2020-01-10|栏目:C#教程|点击: 次
本文实例讲述了C# winForm实现的气泡提示窗口功能。分享给大家供大家参考,具体如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication60 { public partial class Form1 : Form { private Button btnShow = null; private Button btnClose = null; private NotifyIcon notifyIcon1 = null; public Form1() { InitializeComponent(); this.Load+=new EventHandler(Form1_Load); } private void Form1_Load(object sender, EventArgs e) { btnShow = new Button();//显示气泡提示窗口 btnShow.Text = "show"; btnShow.Click += new EventHandler(btnShow_Click); btnShow.Location = new Point(10, 10); this.Controls.Add(btnShow); btnClose = new Button();//影藏气泡提示窗口 btnClose.Text = "close"; btnClose.Click += new EventHandler(btnClose_Click); btnClose.Location = new Point(10 + btnShow.Width + 10, 10); this.Controls.Add(btnClose); notifyIcon1 = new NotifyIcon(); notifyIcon1.MouseMove += new MouseEventHandler(notifyIcon1_MouseMove); notifyIcon1.Icon = global::WindowsFormsApplication60.Properties.Resources.Lintway; } /// <summary> /// 鼠标移过显示时间 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void notifyIcon1_MouseMove(object sender, MouseEventArgs e) { this.notifyIcon1.ShowBalloonTip(1000, "当前时间:", DateTime.Now.ToLocalTime().ToString(), ToolTipIcon.Info);//显示气泡提示 } /// <summary> /// 影藏时间 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnClose_Click(object sender, EventArgs e) { this.notifyIcon1.Visible = false;//设置提示控件不可见 } /// <summary> /// 显示时间 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnShow_Click(object sender, EventArgs e) { this.notifyIcon1.Visible = true;//设置提示控件可见 this.notifyIcon1.ShowBalloonTip(1000, "当前时间:", DateTime.Now.ToLocalTime().ToString(), ToolTipIcon.Info);//显示气泡提示 } } }
更多关于C#相关内容感兴趣的读者可查看本站专题:《C#窗体操作技巧汇总》、《WinForm控件用法总结》、《C#数据结构与算法教程》、《C#常见控件用法教程》、《C#面向对象程序设计入门教程》及《C#程序设计之线程使用技巧总结》
希望本文所述对大家C#程序设计有所帮助。
您可能感兴趣的文章
- 01-10C#通过反射获取当前工程中所有窗体并打开的方法
- 01-10关于ASP网页无法打开的解决方案
- 01-10WinForm限制窗体不能移到屏幕外的方法
- 01-10WinForm绘制圆角的方法
- 01-10C#实现txt定位指定行完整实例
- 01-10C#停止线程的方法
- 01-10WinForm实现仿视频播放器左下角滚动新闻效果的方法
- 01-10C#通过重写Panel改变边框颜色与宽度的方法
- 01-10C#实现清空回收站的方法
- 01-10C#实现读取注册表监控当前操作系统已安装软件变化的方法
阅读排行
本栏相关
- 01-10C#通过反射获取当前工程中所有窗体并
- 01-10关于ASP网页无法打开的解决方案
- 01-10WinForm限制窗体不能移到屏幕外的方法
- 01-10WinForm绘制圆角的方法
- 01-10C#实现txt定位指定行完整实例
- 01-10WinForm实现仿视频播放器左下角滚动新
- 01-10C#停止线程的方法
- 01-10C#实现清空回收站的方法
- 01-10C#通过重写Panel改变边框颜色与宽度的
- 01-10C#实现读取注册表监控当前操作系统已
随机阅读
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 04-02jquery与jsp,用jquery
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-10SublimeText编译C开发环境设置
- 01-10delphi制作wav文件的方法
- 01-11ajax实现页面的局部加载
- 01-10C#中split用法实例总结
- 08-05织梦dedecms什么时候用栏目交叉功能?