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)移過(guò)顯示時(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é)》
希望本文所述對(duì)大家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)簡(jiǎn)單的loading提示控件實(shí)例代碼
- c#消息提示框messagebox的詳解及使用
- C#中TextBox實(shí)現(xiàn)輸入提示功能的方法
- C#程序提示“正由另一進(jìn)程使用,因此該進(jìn)程無(wú)法訪問該文件”的解決辦法
- C#提示:“在證書存儲(chǔ)區(qū)中找不到清單簽名證書”的解決方法
- c# 關(guān)閉窗體時(shí)提示的小例子
- 給 c# 程序員的十個(gè)重要提示
相關(guān)文章
C#生成單頁(yè)靜態(tài)頁(yè)簡(jiǎn)單實(shí)例
這篇文章主要介紹了C#生成單頁(yè)靜態(tài)頁(yè)簡(jiǎn)單實(shí)例,是一個(gè)非常實(shí)用的技巧,需要的朋友可以參考下2014-10-10
C#基于數(shù)據(jù)庫(kù)存儲(chǔ)過(guò)程的AJAX分頁(yè)實(shí)例
這篇文章主要介紹了C#基于數(shù)據(jù)庫(kù)存儲(chǔ)過(guò)程的AJAX分頁(yè)實(shí)現(xiàn)方法,以實(shí)例形式詳細(xì)講述了數(shù)據(jù)庫(kù)存儲(chǔ)過(guò)程的定義、數(shù)據(jù)庫(kù)的訪問及Ajax的實(shí)現(xiàn)技巧,需要的朋友可以參考下2015-01-01
Unity向量按照某一點(diǎn)進(jìn)行旋轉(zhuǎn)
這篇文章主要為大家詳細(xì)介紹了Unity向量按照某一點(diǎn)進(jìn)行旋轉(zhuǎn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-01-01
C#調(diào)用SQL?Server中有參數(shù)的存儲(chǔ)過(guò)程
這篇文章介紹了C#調(diào)用SQL?Server中有參數(shù)存儲(chǔ)過(guò)程的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-03-03

