Line control

Displays simple lines in a window just like good old VB6’s Line control (and later WPF’s Line shape), also with dashed or 3D style.

Lines can be aligned horizontally, vertically or diagonally. They can have a single solid colour or be raised or etched in 3D style.

Compatibility: .NET Version 2.0 or newer

Example

The following image shows a simple example application with several lines in the window.

Screenshot

Download

Line.cs10.1 KiBSource code of the Line control

Usage notes

You need to add a project reference to System.Design to get the full designer functionality. Unfortunately, this is no longer included in the Client Profile since .NET 4.0. You can leave away this reference to not require the Full Profile only to run this application. But then you won’t have all automatic adjustments at design time. You also need to remove or comment out all parts of the code that are rejected by the compiler.

Horizontal and vertical lines are only 1 or 2 pixels tall resp. wide, which is why the Visual Studio designer doesn’t show resize grips for these directions anymore. You can still resize the control: just move the mouse cursor to the end of the line (watch out for the different cursor shape).

Changes

2009Sep18
DashStyle-Eigenschaft hinzugefügt, um z. B. gestrichelte oder gepunktete Linien zu zeichnen.

Licence and terms of use

Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty. (GNU All-Permissive licence)

Statistic data

  • Created on 2007-04-28, updated on 2011-08-28.
  • Ca. 150 lines of code, estimated development costs: 150 - 600 €