本文整理汇总了C#中System.Drawing.StringFormat.HotkeyPrefix属性的典型用法代码示例。如果您正苦于以下问题:C# StringFormat.HotkeyPrefix属性的具体用法?C# StringFormat.HotkeyPrefix怎么用?C# StringFormat.HotkeyPrefix使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Drawing.StringFormat
的用法示例。
在下文中一共展示了StringFormat.HotkeyPrefix属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowHotKey
private void ShowHotKey(PaintEventArgs e)
{
// Declare the string with a keyboard shortcut.
string text = "&Click Here";
// Declare a new StringFormat.
StringFormat format = new StringFormat();
// Set the HotkeyPrefix property.
format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
// Draw the string.
Brush theBrush =
SystemBrushes.FromSystemColor(SystemColors.Highlight);
e.Graphics.DrawString(text, this.Font, theBrush, 30, 40, format);
}
示例2: DrawStringHotkey
//引入命名空间
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Text; // necessary for HotkeyPrefix
public class DrawStringHotkey : Form
{
public DrawStringHotkey()
{
ResizeRedraw = true;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
StringFormat fmt = new StringFormat();
fmt.Alignment = StringAlignment.Center;
fmt.HotkeyPrefix = HotkeyPrefix.Show;
Brush b = new SolidBrush(ForeColor);
g.DrawString("&Do It!", Font, b, ClientSize.Width / 2, 50, fmt);
}
static void Main()
{
Application.Run(new DrawStringHotkey());
}
}