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.
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 |
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.
When the pointer moves onto the form, it changes to a cross hair.