SystemBrushes 类

SystemBrushes 类的每个属性都是一个 SolidBrush,它是 Windows 显示元素的颜色。

**命名空间:**System.Drawing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public NotInheritable Class SystemBrushes
用法
Dim instance As SystemBrushes
public sealed class SystemBrushes
public ref class SystemBrushes sealed
public final class SystemBrushes
public final class SystemBrushes

示例

下面的代码示例演示如何使用 HotkeyPrefix 属性设置键盘快捷键。它还演示如何使用 FromSystemColor 方法。若要运行此示例,请将代码粘贴到一个窗体中,处理该窗体的 Paint 事件并调用下面的方法,将 e 作为 PaintEventArgs 传递。

Private Sub ShowHotKey(ByVal e As PaintEventArgs)

    ' Declare the string with keyboard shortcut.
    Dim text As String = "&Click Here"

    ' Declare a new StringFormat.
    Dim format As New StringFormat

    ' Set the HotkeyPrefix property.
    format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show

    ' Draw the string.
    Dim theBrush As Brush = _
        SystemBrushes.FromSystemColor(SystemColors.Highlight)
    e.Graphics.DrawString(text, Me.Font, theBrush, 30, 40, format)
End Sub
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);
}
private:
   void ShowHotKey( PaintEventArgs^ e )
   {
      // Declare the string with a keyboard shortcut.
      String^ text = "&Click Here";

      // Declare a new StringFormat.
      StringFormat^ format = gcnew 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 );
   }
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.set_HotkeyPrefix(System.Drawing.Text.HotkeyPrefix.Show);

    // Draw the string.
    Brush theBrush = SystemBrushes.FromSystemColor(
        SystemColors.get_Highlight());

    e.get_Graphics().DrawString(text, this.get_Font(), theBrush, 30, 40, 
        format);
} //ShowHotKey

继承层次结构

System.Object
  System.Drawing.SystemBrushes

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

SystemBrushes 成员
System.Drawing 命名空间