This documentation is archived and is not being maintained.

Graphics.DrawLines Method

Draws a series of line segments that connect an array of Point structures.

Overload List

Draws a series of line segments that connect an array of Point structures.

[Visual Basic] Overloads Public Sub DrawLines(Pen, Point())
[C#] public void DrawLines(Pen, Point[]);
[C++] public: void DrawLines(Pen*, Point[]);
[JScript] public function DrawLines(Pen, Point[]);

Draws a series of line segments that connect an array of PointF structures.

[Visual Basic] Overloads Public Sub DrawLines(Pen, PointF())
[C#] public void DrawLines(Pen, PointF[]);
[C++] public: void DrawLines(Pen*, PointF[]);
[JScript] public function DrawLines(Pen, PointF[]);

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The performs the following actions:

  • Code creates a black pen.
  • Creates an array of points of segments of the line.
  • Draws the connected line segments to the screen.
[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of DrawLines. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub DrawLinesPointF(e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create array of points that define lines to draw.
Dim points As PointF() =  {New PointF(10F, 10F), _
New PointF(10F, 100F), New PointF(200F, 50F), _
New PointF(250F, 300F)}
'Draw lines to screen.
e.Graphics.DrawLines(blackPen, points)
End Sub
        
[C#] 
public void DrawLinesPointF(PaintEventArgs e)
{
// Create pen.
Pen pen = new Pen(Color.Black, 3);
// Create array of points that define lines to draw.
PointF[] points =
{
new PointF( 10.0F,  10.0F),
new PointF( 10.0F, 100.0F),
new PointF(200.0F,  50.0F),
new PointF(250.0F, 300.0F)
};
//Draw lines to screen.
e.Graphics.DrawLines(pen, points);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

Show: