---
title: "GdiGraphics..::.DrawLine Method (Pen, Int32, Int32, Int32, Int32)"
canonical: https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Drawing_GdiGraphics_DrawLine_5_943d79c1.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# GdiGraphics.DrawLine Method (Pen, Int32, Int32, Int32, Int32)
 
Draws a line.
 
**Namespace:** [Aurigma.GraphicsMill.Drawing](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Drawing.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
Public Sub DrawLine ( _pen As Pen, _x1 As Integer, _y1 As Integer, _x2 As Integer, _y2 As Integer _
)
```
 
```csharp
public void DrawLine(Pen pen,int x1,int y1,int x2,int y2
)
```
 
### Parameters
 
 - pen
     - Type: [Aurigma.GraphicsMill.Drawing.Pen](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Drawing_Pen.htm.md)
 [Pen](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Drawing_Pen.htm.md) object which is used to draw a line.

 - x1
     - Type: [System.Int32](http://msdn2.microsoft.com/en-us/td2s409d)
X-coordinate of the start point of the line.

 - y1
     - Type: [System.Int32](http://msdn2.microsoft.com/en-us/td2s409d)
Y-coordinate of the start point of the line.

 - x2
     - Type: [System.Int32](http://msdn2.microsoft.com/en-us/td2s409d)
X-coordinate of the end point of the line.

 - y2
     - Type: [System.Int32](http://msdn2.microsoft.com/en-us/td2s409d)
Y-coordinate of the end point of the line.
 
## Remarks
 In this method line is defined with two points which should be connected with this line. 
All the coordinates are measured in units specified with [Unit](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_UnitConverterObject_Unit.htm.md) property.
 
## Examples
  
```
Dim gdiGraphics As Aurigma.GraphicsMill.Drawing.GdiGraphics = _
 Aurigma.GraphicsMill.Drawing.GdiGraphics.FromHwnd(PictureBox1.Handle)

Dim pen As New Aurigma.GraphicsMill.Drawing.Pen(Aurigma.GraphicsMill.RgbColor.Red, 1)

gdiGraphics.DrawLine(pen, 50, 0, 50, 100)
```
 
```csharp
Aurigma.GraphicsMill.Drawing.GdiGraphics gdiGraphics =
    Aurigma.GraphicsMill.Drawing.GdiGraphics.FromHwnd(PictureBox1.Handle);

Aurigma.GraphicsMill.Drawing.Pen pen =
    new Aurigma.GraphicsMill.Drawing.Pen(Aurigma.GraphicsMill.RgbColor.Red, 1);

gdiGraphics.DrawLine(pen, 50, 0, 50, 100);
```
   
## See Also

### Reference

- [GdiGraphics Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Drawing_GdiGraphics.htm.md)
- [DrawLine Overload](https://www.graphicsmill.com/docs/gm5/O_T_Aurigma_GraphicsMill_Drawing_GdiGraphics_DrawLine.htm.md)
- [Aurigma.GraphicsMill.Drawing Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Drawing.htm.md)
