Font.Bold 属性

获取一个值,该值指示此 Font 是否为粗体。

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

语法

声明
Public ReadOnly Property Bold As Boolean
用法
Dim instance As Font
Dim value As Boolean

value = instance.Bold
public bool Bold { get; }
public:
property bool Bold {
    bool get ();
}
/** @property */
public boolean get_Bold ()
public function get Bold () : boolean

属性值

如果此 Font 为粗体,则为 true;否则为 false

示例

下面的代码示例演示 op_Inequality 运算符、Font 构造函数和 Bold 属性。此示例用于包含 Button2 按钮的 Windows 窗体。将下面的代码粘贴到您的窗体中,并将 Button2_Click 方法与该按钮的 Click 事件关联。

Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click

    If (Color.op_Inequality(Me.BackColor, SystemColors.ControlDark)) Then
        Me.BackColor = SystemColors.ControlDark
    End If
    If Not (Me.Font.Bold) Then
        Me.Font = New Font(Me.Font, FontStyle.Bold)
    End If
End Sub
private void Button2_Click(System.Object sender, System.EventArgs e)
{

    if (this.BackColor != SystemColors.ControlDark)
    {
        this.BackColor = SystemColors.ControlDark;
    }
    if (!(this.Font.Bold))
    {
        this.Font = new Font(this.Font, FontStyle.Bold);
    }
}
void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   if ( this->BackColor != SystemColors::ControlDark )
   {
      this->BackColor = SystemColors::ControlDark;
   }

   if (  !(this->Font->Bold) )
   {
      this->Font = gcnew System::Drawing::Font( this->Font,FontStyle::Bold );
   }
}
private void button2_Click(System.Object sender, System.EventArgs e)
{
    if (!(this.get_BackColor().Equals(SystemColors.get_ControlDark()))) {
        this.set_BackColor(SystemColors.get_ControlDark());
    }
    if (!(this.get_Font().get_Bold())) {
        this.set_Font(new Font(this.get_Font(), FontStyle.Bold));
    }
} //button2_Click

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、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

请参见

参考

Font 类
Font 成员
System.Drawing 命名空间