Font.Clone 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建此 Font的确切副本。
public:
virtual System::Object ^ Clone();
public object Clone ();
abstract member Clone : unit -> obj
override this.Clone : unit -> obj
Public Function Clone () As Object
返回
实现
示例
下面的代码示例设计用于 Windows 窗体,它需要 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