Font.Clone 方法

定義

建立這個 Font 的完全相同複本。

public:
 virtual System::Object ^ Clone();
public object Clone ();
abstract member Clone : unit -> obj
override this.Clone : unit -> obj
Public Function Clone () As Object

傳回

這個方法所建立的 Font,它轉換為 Object

實作

範例

下列程式碼範例的設計目的是要與Windows Forms搭配使用,而且需要 PaintEventArgse ,這是事件處理常式的參數 Paint 。 程式碼會複製 , Font 並使用該字型繪製文字。

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.Graphics.DrawString("This is a cloned font", cloneFont,
        Brushes.Black, 0, 0);
}
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

適用於