次の方法で共有


Font.Clone メソッド

対象の Font オブジェクトの同一コピーを作成します。

Public Overridable Function Clone() As Object Implements _   ICloneable.Clone
[C#]
public virtual object Clone();
[C++]
public: virtual Object* Clone();
[JScript]
public function Clone() : Object;

戻り値

このメソッドが作成し、object としてキャストされる Font オブジェクト。

実装

ICloneable.Clone

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードでは、 Font オブジェクトのクローンを作成し、そのフォントでテキストを描画します。

 
Public Sub Clone_Example(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
        
[C#] 
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);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

Font クラス | Font メンバ | System.Drawing 名前空間