All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
C#教程:创建Web服务
总结:关于ASP.NET,2.0一些简单而有用的技巧_.net资料_编程技术
ASP.NET组件DataGrid的分页实用方法_.net资料_编程技术
Ajax技术实践之完成Ajax自动完成功能_[AJAX教程]
在C#中使用帮助文件
如何在PHP中进行身份认证_[PHP教程]
SQL,Server的恢复模式_mssql学习_编程技术
php程序获得访问者ip的代码_[PHP教程]
mysql,设置,log,保留天数_mssql学习_编程技术
PHP实现上传文件生成小图加文字的实例_php资料_编程技术
Reading number is top 10 pictures
Born After 90 Beijing sports university campus flower photos5
美女浴室写真3
The most popular girls welcome eggplant
Nikon microscopic photography of the first three
Sora aoi possession photo1
Other people's teacher VS my teacher
A man's favorite things15
So beauty, will let you spray blood10
人美胸美腿更美4
这才是真正的人体艺术2
Download software ranking
双旗镇刀客A
Dance with duck(male prostitution)
电车之狼R
Boxer vs Yellow1
I'm come from Beijing2
Eclipse-CALMSANNY (second edition)
Boxer's Top ten classic battle8
Ashlynn Video1
WebService在.NET中的实战应用教学视频 → 第2集
jdk1.5
qq published in(发表于) 2014/7/11 9:17:35 Edit(编辑)
C#中NotifyIcon控件应用实例

C#中NotifyIcon控件应用实例

C#中NotifyIcon控件应用实例

NotifyIcon控件

1.功能

NotifyIcon控件通常用于显示在后台运行的进程的图标,这些进程大部分时间不显示用户界面。每个NotifyIcon控件都在状态栏区域显示一个图标。如果有3个后台进程,并希望为每个后台进程各显示一个图标,则需要添加3个NotifyIcon控件。图1所示为NotifyIcon控件。



图1 NotifyIcon控件

2.属性

NotifyIcon控件常用属性及说明如表1所示。



表1 NotifyIcon控件常用属性及说明

下面对比较重要的属性进行详细介绍。

(1)Visible属性。

语法:

public bool Visible { get; set; }

属性值:如果图标在通知区域中可见,则为True;否则为False。默认值为False。

(2)BalloonTipIcon属性。

语法:

public ToolTipIcon BalloonTipIcon { get; set; }

属性值:要显示在与NotifyIcon关联的气球提示上的ToolTipIcon。

示例

BalloonTipIcon属性设置

本示例中,当程序运行时,在窗体中单击鼠标右键,弹出一个“退出”快捷菜单,同时在状态栏中显示一个小人图标。示例运行结果如图2所示。



图2 BalloonTipIcon属性效果

程序主要代码如下:

notifyIcon1.Visible = True;

完整程序代码如下:

★★★★★主程序文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace _8_12

{

static class Program

{

///



/// 应用程序的主入口点。

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new frmNotifyIcon());

}

}

}

★★★★★frmNotifyIcon窗体设计文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _8_12

{

public partial class frmNotifyIcon : Form

{

public frmNotifyIcon()

{

InitializeComponent();

}

private void frmNotifyIcon_Load(object sender, EventArgs e)

{

notifyIcon1.Visible = true;

}

private void notifyIcon1_DoubleClick(object sender, EventArgs e)

{

}

private void 退出EToolStripMenuItem_Click(object sender, EventArgs e)

{

Application.Exit();

}

}

}

★★★★★frmNotifyIcon窗体代码文件完整程序代码★★★★★

namespace _8_12

{

partial class frmNotifyIcon

{

///

/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmNotifyIcon));

this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);

this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);

this.退出EToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();

this.label1 = new System.Windows.Forms.Label();

this.contextMenuStrip1.SuspendLayout();

this.SuspendLayout();

//

// notifyIcon1

//

this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.