You don't need an additional .dll. The ability to draw a line comes with .NET framework for free. Here is how it's done:
Draw your special line onto one of your controls.
Version 1
Attach a method to the underlying control's
Paint
event.
BaseControl.Paint += new PaintEventHandler(BaseControl_Paint);
The method now is called a paint event handler. It will have an argument of type
PaintEventArgs
, often called "e".
In your paint event handler, call
private void BaseControl_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(Pens.Orange, firstPoint, secondPoint);
}
An orange line will be drawn from the first point to the second. Points are in co-ordinates of the underlying control with (0,0) in the control's upper left corner.
Version 2
Subclass the underlying control and override
OnPaint
:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawLine(Pens.Orange, firstPoint, secondPoint);
}
It's important that you call your
DrawLine()
after base.OnPaint()
in order to draw on top of the underlying control. Otherwise your line would get painted over and never been seen.