FontDialog.ShowColor 属性

定义

获取或设置一个值,该值指示对话框是否显示颜色选择。

public:
 property bool ShowColor { bool get(); void set(bool value); };
public bool ShowColor { get; set; }
member this.ShowColor : bool with get, set
Public Property ShowColor As Boolean

属性值

Boolean

如果对话框显示颜色选择,值为 true;反之,值为 false。 默认值是 false

示例

下面的代码示例用于ShowDialog显示 。FontDialog 此代码要求 Form 已创建一个并 TextBox 放置有按钮的帐户。 它还要求 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

适用于

另请参阅