Freigeben über


Font.Clone-Methode

Erstellt eine genaue Kopie von diesem Font.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

Syntax

'Declaration
Public Function Clone As Object
'Usage
Dim instance As Font
Dim returnValue As Object

returnValue = instance.Clone
public Object Clone ()
public:
virtual Object^ Clone () sealed
public final Object Clone ()
public final function Clone () : Object

Rückgabewert

Der von dieser Methode erstellte Font, umgewandelt in ein Object.

Beispiel

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms vorgesehen und erfordert PaintEventArgse, wobei es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code klont einen Font und zeichnet Text in dieser Schriftart.

Public Sub Clone_Example(ByVal e As PaintEventArgs)

    ' Create a Font object.
    Dim myFont As New Font("Arial", 16)

    ' Create a copy of myFont.
    Dim cloneFont As Font = CType(myFont.Clone(), Font)

    ' Use cloneFont to draw text to the screen.
    e.Graphics.DrawString("This is a cloned font", cloneFont, _
    Brushes.Black, 0, 0)
End Sub
public void Clone_Example(PaintEventArgs e)
{
    // Create a Font object.
    Font myFont = new Font("Arial", 16);
             
    // Create a copy of myFont.
    Font cloneFont = (Font)myFont.Clone();
             
    // Use cloneFont to draw text to the screen.
    e.Graphics.DrawString("This is a cloned font", cloneFont,
        Brushes.Black, 0, 0);
}
public:
   void Clone_Example( PaintEventArgs^ e )
   {
      // Create a Font object.
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",16 );

      // Create a copy of myFont.
      System::Drawing::Font^ cloneFont = dynamic_cast<System::Drawing::Font^>(myFont->Clone());

      // Use cloneFont to draw text to the screen.
      e->Graphics->DrawString( "This is a cloned font", cloneFont, Brushes::Black, 0, 0 );
   }
public void Clone_Example(PaintEventArgs e) 
{
     // Create a Font object.
     Font myFont =  new Font("Arial", 16);
     
     // Create a copy of myFont.
     Font cloneFont = (Font)myFont.Clone();
     
     // Use cloneFont to draw text to the screen.
     e.get_Graphics().DrawString("This is a cloned font", cloneFont,
        Brushes.get_Black(), 0, 0);
 } //Clone_Example

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

.NET Compact Framework

Unterstützt in: 2.0

Siehe auch

Referenz

Font-Klasse
Font-Member
System.Drawing-Namespace