C# winForm實(shí)現(xiàn)的氣泡提示窗口功能示例
本文實(shí)例講述了C# winForm實(shí)現(xiàn)的氣泡提示窗口功能。分享給大家供大家參考,具體如下:
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> /// 鼠標(biāo)移過顯示時(shí)間 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void notifyIcon1_MouseMove(object sender, MouseEventArgs e) { this.notifyIcon1.ShowBalloonTip(1000, "當(dāng)前時(shí)間:", DateTime.Now.ToLocalTime().ToString(), ToolTipIcon.Info);//顯示氣泡提示 } /// <summary> /// 影藏時(shí)間 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnClose_Click(object sender, EventArgs e) { this.notifyIcon1.Visible = false;//設(shè)置提示控件不可見 } /// <summary> /// 顯示時(shí)間 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnShow_Click(object sender, EventArgs e) { this.notifyIcon1.Visible = true;//設(shè)置提示控件可見 this.notifyIcon1.ShowBalloonTip(1000, "當(dāng)前時(shí)間:", DateTime.Now.ToLocalTime().ToString(), ToolTipIcon.Info);//顯示氣泡提示 } } }
更多關(guān)于C#相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《C#窗體操作技巧匯總》、《WinForm控件用法總結(jié)》、《C#數(shù)據(jù)結(jié)構(gòu)與算法教程》、《C#常見控件用法教程》、《C#面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》及《C#程序設(shè)計(jì)之線程使用技巧總結(jié)》
希望本文所述對大家C#程序設(shè)計(jì)有所幫助。
- c# 設(shè)置TeeChart控件的提示文本
- C#瀏覽器提示跨域問題解決方案
- C#實(shí)現(xiàn)倒計(jì)時(shí)關(guān)閉提示框功能
- C#實(shí)現(xiàn)狀態(tài)欄提示信息功能的示例
- 解決C#調(diào)用dll提示
- C#實(shí)現(xiàn)簡單的loading提示控件實(shí)例代碼
- c#消息提示框messagebox的詳解及使用
- C#中TextBox實(shí)現(xiàn)輸入提示功能的方法
- C#程序提示“正由另一進(jìn)程使用,因此該進(jìn)程無法訪問該文件”的解決辦法
- C#提示:“在證書存儲(chǔ)區(qū)中找不到清單簽名證書”的解決方法
- c# 關(guān)閉窗體時(shí)提示的小例子
- 給 c# 程序員的十個(gè)重要提示
相關(guān)文章
基于C#實(shí)現(xiàn)的端口掃描器實(shí)例代碼
這篇文章主要介紹了基于C#實(shí)現(xiàn)的端口掃描器實(shí)例代碼,需要的朋友可以參考下2014-07-07C#實(shí)現(xiàn)DataTable,List和Json轉(zhuǎn)換的方法
這篇文章主要介紹了C#實(shí)現(xiàn)DataTable,List和Json轉(zhuǎn)換的方法,結(jié)合實(shí)例形式分析了DataTable、list、DataReader、DataSet等轉(zhuǎn)換成JSON的相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-08-08解讀在C#中winform程序響應(yīng)鍵盤事件的詳解
本篇文章是對在C#中winform程序響應(yīng)鍵盤事件的詳細(xì)介紹,需要的朋友參考下2013-05-05C#實(shí)現(xiàn)將PDF轉(zhuǎn)為線性化PDF
線性化PDF文件是PDF文件的一種特殊格式,可以通過Internet更快地進(jìn)行查看。這篇文章主要介紹了如何通過C#實(shí)現(xiàn)將PDF轉(zhuǎn)為線性化PDF,感興趣的小伙伴可以學(xué)習(xí)一下2021-12-12