Pen.Clone Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates an exact copy of this Pen.
public:
virtual System::Object ^ Clone();
public object Clone ();
abstract member Clone : unit -> obj
override this.Clone : unit -> obj
Public Function Clone () As Object
Returns
An Object that can be cast to a Pen.
Implements
Examples
The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e
, which is a parameter of the Paint event handler. The code performs the following actions:
Creates a Pen.
Creates a copy of that pen.
Draws a line to the screen, using the copy of the pen.
public:
void Clone_Example( PaintEventArgs^ e )
{
// Create a Pen object.
Pen^ myPen = gcnew Pen( Color::Black,5.0f );
// Clone myPen.
Pen^ clonePen = dynamic_cast<Pen^>(myPen->Clone());
// Draw a line with clonePen.
e->Graphics->DrawLine( clonePen, 0, 0, 100, 100 );
}
public void Clone_Example(PaintEventArgs e)
{
// Create a Pen object.
Pen myPen = new Pen(Color.Black, 5);
// Clone myPen.
Pen clonePen = (Pen)myPen.Clone();
// Draw a line with clonePen.
e.Graphics.DrawLine(clonePen, 0, 0, 100, 100);
}
Public Sub Clone_Example(ByVal e As PaintEventArgs)
' Create a Pen object.
Dim myPen As New Pen(Color.Black, 5)
' Clone myPen.
Dim clonePen As Pen = CType(myPen.Clone(), Pen)
' Draw a line with clonePen.
e.Graphics.DrawLine(clonePen, 0, 0, 100, 100)
End Sub
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET