Freigeben über


FontDialog.Font-Eigenschaft

Ruft die ausgewählte Schriftart ab oder legt diese fest.

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

Syntax

'Declaration
Public Property Font As Font
'Usage
Dim instance As FontDialog
Dim value As Font

value = instance.Font

instance.Font = value
public Font Font { get; set; }
public:
property Font^ Font {
    Font^ get ();
    void set (Font^ value);
}
/** @property */
public Font get_Font ()

/** @property */
public void set_Font (Font value)
public function get Font () : Font

public function set Font (value : Font)

Eigenschaftenwert

Die ausgewählte Schriftart.

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
Font
FontDialog.Color-Eigenschaft