System.Drawing.Graphics.DrawLine C# (CSharp) Method

DrawLine() public method

public DrawLine ( Pen pen, float x1, float y1, float x2, float y2 ) : void
pen Pen
x1 float
y1 float
x2 float
y2 float
return void
        public void DrawLine(Pen pen, float x1, float y1, float x2, float y2)
        {
            if (pen == null)
                throw new ArgumentNullException ("pen");

            MoveTo (x1, y1);
            LineTo (x2, y2);
            StrokePen (pen);
        }

Same methods

Graphics::DrawLine ( Pen pen, Point pt1, Point pt2 ) : void
Graphics::DrawLine ( Pen pen, PointF pt1, PointF pt2 ) : void
Graphics::DrawLine ( Pen pen, int x1, int y1, int x2, int y2 ) : void

Usage Example

Example #1
1
        public void Draw(Graphics g)
        {
            Pen p = new Pen(Color.Green, 1f);

            g.DrawLine(p, 0, height / 2, width, height / 2);
            g.DrawLine(p, width / 2, 0, width / 2, height);
        }
All Usage Examples Of System.Drawing.Graphics::DrawLine