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

Reading number is top 10 articles
实例分析学习动态网页制作技术PHP开发投票系统_php资料_编程技术
9个实用PHP函数及用法_[PHP教程]
在ASP.NET,2.0中建立站点导航层次_[Asp.Net教程]
利用WebClient和WebRequest类获得网页源代码_[Asp.Net教程]
详解aspx页面事件的执行顺序_[Asp.Net教程]
Asp.net2.0实现Word转换Html,同时分享系列笑话_[Asp.Net教程]
php-树形结构的算法_[PHP教程]
ASP.NET,MVC,Framework体验(1):从一个简单实例开始_[Asp.Net教程]
XP下Asp.net访问被拒绝_[Asp.Net教程]
.NET,2.0,中的自定义配置处理_[Asp.Net教程]
Reading number is top 10 pictures
Sanya, hainan Haitian party feast promiscuity
The world's top ten most beautiful railway station2
Thrilling English baby
The money of more than 100 countries and regions11
小学生作文又现神作,你不得不佩服
全球清廉国家排行
China's ambassador to Libya embassy was shock, and the glass is broken in
八个盛产美女的国家2
美女和狗狗2
The real super beauty5
Download software ranking
虚拟机汉化软件
塘西风月痕
I'm come from Beijing2
豪门浪荡史
Tram sex maniac 2 (H) rar bag13
圣殿祭司的ASP.NET.2.0.开发详解-使用C#
dreamweaver8中文版
linux安装大全
Eclipse-CALMSANNY (second edition)
Photoshop 8.0图象编辑软件
qq published in(发表于) 2014/7/11 9:23:20 Edit(编辑)
C#教程:使用键盘热键实例

C#教程:使用键盘热键实例

C#教程:使用键盘热键实例|方法

使用键盘热键

编写应用程序时,经常会遇到使用键盘热键的情况。使用键盘热键不仅方便操作软件,而且能够大大地提高工作效率。

热键通常在控件的text属性中设置,下面以设置Button控件的热键为例,详细介绍设置热键的步骤。具体操作步骤如下。

(1)在窗体中添加一个Button控件,在该控件的属性窗口中找到Text属性,并输入要显示的文本及热键。输入热键的方法是将输入法切换到英文状态下,输入左右小括号“()”,然后在括号内输入组合字符“&T”,运行效果如图1所示。



图1 热键设置

(2)当程序运行时,想要激活热键,按下组合键即可。

示例

热键的使用

本示例中,按下热键,弹出消息对话框,示例运行结果如图2所示。



图2 热键效果

private void button1_Click(object sender, EventArgs e)

{

MessageBox.Show("快捷方便的热键");

}

完整程序代码如下:

★ ★★★★frmHot.cs窗体代码文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _2_10

{

public partial class frmHot : Form

{

public frmHot()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

MessageBox.Show("快捷方便的热键");

}

private void frmHot_Load(object sender, EventArgs e)

{

}

}

}

★ ★★★★frmHot.designer.cs窗体设计文件完整程序代码★★★★★

namespace _2_10

{

partial class frmHot

{

///



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

///


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.button1 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(92, 45);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "热键(&T)";

this.button1.UseVisualStyleBackColor = true;

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// frmHot

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(292, 132);

this.Controls.Add(this.button1);

this.Name = "frmHot";

this.Text = "热键";

this.Load += new System.EventHandler(this.frmHot_Load);

this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Button button1;

}

}

★ ★★★★Program.cs主程序文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace _2_10

{

static class Program

{

///

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

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new frmHot());

}

}

}




添加到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.