Freigeben über


FontDialog.ShowColor-Eigenschaft

Ruft einen Wert ab, der angibt, ob im Dialogfeld die Farbauswahl angezeigt wird, oder legt diesen fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property ShowColor As Boolean
'Usage
Dim instance As FontDialog
Dim value As Boolean

value = instance.ShowColor

instance.ShowColor = value
public bool ShowColor { get; set; }
public:
property bool ShowColor {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_ShowColor ()

/** @property */
public void set_ShowColor (boolean value)
public function get ShowColor () : boolean

public function set ShowColor (value : boolean)

Eigenschaftenwert

true, wenn im Dialogfeld die Farbauswahl angezeigt wird, andernfalls false. Der Standardwert ist false.

Beispiel

Im folgenden Codebeispiel wird ShowDialog zum Anzeigen eines FontDialog verwendet. Voraussetzung für diesen Code ist, dass Form bereits mit TextBox erstellt wurde und Schaltflächen darauf platziert sind. Weiterhin wird davon ausgegangen, dass fontDialog1 erstellt wurde. Font enthält die Größeninformationen, jedoch nicht die Farbinformationen.

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 'button1_Click
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;
      }
   }
protected void button1_Click(Object sender, System.EventArgs e)
{
    fontDialog1.set_ShowColor(true);
    fontDialog1.set_Font(textBox1.get_Font());
    fontDialog1.set_Color(textBox1.get_ForeColor());
    if (!(fontDialog1.ShowDialog().Equals(get_DialogResult().Cancel))) {
        textBox1.set_Font(fontDialog1.get_Font());
        textBox1.set_ForeColor(fontDialog1.get_Color());
    }
} //button1_Click

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

FontDialog-Klasse
FontDialog-Member
System.Windows.Forms-Namespace
FontDialog.Color-Eigenschaft
FontDialog.ShowApply-Eigenschaft
ShowEffects
ShowHelp