FontDialog.Color 属性

定义

获取或设置选定字体的颜色。

public:
 property System::Drawing::Color Color { System::Drawing::Color get(); void set(System::Drawing::Color value); };
public System.Drawing.Color Color { get; set; }
member this.Color : System.Drawing.Color with get, set
Public Property Color As Color

属性值

选定字体的颜色。 默认值是 Black

示例

下面的代码示例使用 ShowDialog 来显示 FontDialog。 此代码要求已创建 TextBoxForm放置了 按钮的 。 它还要求 fontDialog1 已创建 。 包含 Font 大小信息,但不包含颜色信息。

private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      fontDialog1->ShowColor = true;

      fontDialog1->Font = textBox1->Font;
      fontDialog1->Color = textBox1->ForeColor;

      if ( fontDialog1->ShowDialog() != ::DialogResult::Cancel )
      {
         textBox1->Font = fontDialog1->Font;
         textBox1->ForeColor = fontDialog1->Color;
      }
   }
private void button1_Click(object sender, System.EventArgs e)
 {
    fontDialog1.ShowColor = true;

    fontDialog1.Font = textBox1.Font;
    fontDialog1.Color = textBox1.ForeColor;

    if(fontDialog1.ShowDialog() != DialogResult.Cancel )
    {
       textBox1.Font = fontDialog1.Font ;
       textBox1.ForeColor = fontDialog1.Color;
    }
 }
Private Sub button1_Click(sender As Object, e As System.EventArgs)
    fontDialog1.ShowColor = True

    fontDialog1.Font = textBox1.Font
    fontDialog1.Color = textBox1.ForeColor

    If fontDialog1.ShowDialog() <> DialogResult.Cancel Then
        textBox1.Font = fontDialog1.Font
        textBox1.ForeColor = fontDialog1.Color
    End If
End Sub

适用于

另请参阅