本文整理汇总了C#中System.Windows.Forms.KeyEventArgs.Alt属性的典型用法代码示例。如果您正苦于以下问题:C# KeyEventArgs.Alt属性的具体用法?C# KeyEventArgs.Alt怎么用?C# KeyEventArgs.Alt使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.KeyEventArgs
的用法示例。
在下文中一共展示了KeyEventArgs.Alt属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: textBox1_KeyDown
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
// Determine whether the key entered is the F1 key. If it is, display Help.
if(e.KeyCode == Keys.F1 && (e.Alt || e.Control || e.Shift))
{
// Display a pop-up Help topic to assist the user.
Help.ShowPopup(textBox1, "Enter your name.", new Point(textBox1.Bottom, textBox1.Right));
}
else if(e.KeyCode == Keys.F2 && e.Modifiers == Keys.Alt)
{
// Display a pop-up Help topic to provide additional assistance to the user.
Help.ShowPopup(textBox1, "Enter your first name followed by your last name. Middle name is optional.",
new Point(textBox1.Top, this.textBox1.Left));
}
}
示例2: treeView1_KeyDown
private void treeView1_KeyDown(object sender, KeyEventArgs e)
{
/* If the 'Alt' and 'E' keys are pressed,
* allow the user to edit the TreeNode label. */
if(e.Alt && e.KeyCode == Keys.E)
{
treeView1.LabelEdit = true;
// If there is a TreeNode under the mouse cursor, begin editing.
TreeNode editNode = treeView1.GetNodeAt(
treeView1.PointToClient(System.Windows.Forms.Control.MousePosition));
if(editNode != null)
{
editNode.BeginEdit();
}
}
}
private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
{
// Disable the ability to edit the TreeNode labels.
treeView1.LabelEdit = false;
}
示例3: KeyDemo
//引入命名空间
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public class KeyDemo : System.Windows.Forms.Form
{
private System.Windows.Forms.Label charLabel;
private System.Windows.Forms.Label keyInfoLabel;
public KeyDemo()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.charLabel = new System.Windows.Forms.Label();
this.keyInfoLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
this.charLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
this.charLabel.Location = new System.Drawing.Point(8, 8);
this.charLabel.Name = "charLabel";
this.charLabel.Size = new System.Drawing.Size(168, 32);
this.charLabel.TabIndex = 0;
this.keyInfoLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
this.keyInfoLabel.Location = new System.Drawing.Point(8, 56);
this.keyInfoLabel.Name = "keyInfoLabel";
this.keyInfoLabel.Size = new System.Drawing.Size(168, 136);
this.keyInfoLabel.TabIndex = 0;
this.AutoScaleBaseSize = new System.Drawing.Size(15, 37);
this.ClientSize = new System.Drawing.Size(184, 197);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.keyInfoLabel,this.charLabel});
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F);
this.Name = "Key Demo";
this.Text = "Key Demo";
this.KeyDown +=new System.Windows.Forms.KeyEventHandler(this.KeyDemo_KeyDown );
this.KeyPress +=new System.Windows.Forms.KeyPressEventHandler(this.KeyDemo_KeyPress );
this.KeyUp +=new System.Windows.Forms.KeyEventHandler(this.KeyDemo_KeyUp );
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.Run( new KeyDemo() );
}
protected void KeyDemo_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e )
{
charLabel.Text = "Key pressed: " + e.KeyChar;
}
private void KeyDemo_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e )
{
keyInfoLabel.Text =
"Alt: " + (e.Alt ? "Yes" : "No") + '\n' +
"Shift: " + (e.Shift ? "Yes" : "No" ) + '\n' +
"Ctrl: " + (e.Control ? "Yes" : "No" ) + '\n' +
"KeyCode: " + e.KeyCode + '\n' +
"KeyData: " + e.KeyData + '\n' +
"KeyValue: " + e.KeyValue;
}
private void KeyDemo_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e )
{
Console.WriteLine("Key up");
}
}