Graphics::DrawLine Method (Pen^, Point, Point)
.NET Framework (current version)
Draws a line connecting two Point structures.
System.Drawing (in System.Drawing.dll)
The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code performs the following actions:
void DrawLinePoint( PaintEventArgs^ e )
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create points that define line.
Point point1 = Point(100,100);
Point point2 = Point(500,100);
// Draw line to screen.
e->Graphics->DrawLine( blackPen, point1, point2 );
Return to top
Available since 1.1