Line Control

The Line control is used to create simple line segments on a form, a frame, or in a picture box. You can control the position, length, color, and style of line controls to customize the look of applications. The Line control has limited functionality and is intended for simple uses—display and printing. Line segments cannot be joined to form other shapes, for instance. For more advanced uses you need to use the DrawLine method.

Syntax

Line

The Line control has the following properties, methods, and events.

Properties Methods Events
BorderColor Refresh
BorderStyle ZOrder
BorderWidth
Container
DrawMode
Name
Parent
Tag
Visible
X1,Y1,X2,Y2

Remarks

You can set the color and style of a line segment by using the BorderStyle and BorderColor properties.

You can specify a line style at design time by choosing the BorderStyle property from the Properties window of the Line control or, at run time, by specifying the style using its equivalent constant in code.

The BorderColor property is used to specify the color of the line.

At design time, you can set the line color by choosing the BorderColor property from the Properties window of the Line control and then selecting from the available palette or system colors.

To set colors at run time, use a color constant or the RGB function to specify border colors. When BorderStyle is set to 0, the BorderColor property is ignored.

You can move or resize the line control at run time by altering its X1, X2, Y1, and Y2 properties. The X1 and Y1 properties set the horizontal and vertical positions of the left end of the line segment. The X2 and Y2 properties set the horizontal and vertical positions of the right end of the line segment. You cannot move a line segment using the Move method.

    To draw a line on a form

  1. In the toolbox, select the Line control.

    When the pointer moves onto the form, it changes to a cross hair.

  2. Click the form where you want the line to begin and hold down the mouse button.
  3. Drag the cross hair to where you want the line to end and release the mouse button.
  4. From the Properties window, select the BorderStyle property if you want to change the appearance of the line.
  5. In the Settings box, select the style you want.