Visual Basic Concepts
The line control is used to create simple line segments on a form, a frame, or in a picture box.
Figure 7.30 The line control
You can control the position, length, color, and style of line controls to customize the look of applications. Figure 7.31 shows a line control used to graphically separate the label containing the text "Company Name" from the rest of the form.
Figure 7.31 A line control on a form
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 line method.
For More Information See "Using Graphics Methods" in "Working with Text and Graphics" for more information on drawing lines, rectangles, and filled-in boxes at run time using the line method or for more information on drawing circles, ellipses, and arcs at run time using the Circle method.
You set the color and style of a line segment by using the BorderStyle and BorderColor properties.
The BorderStyle property provides you with six line styles:
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 Visual Basic constant in code.
The BackColor 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 the Visual Basic color constants (vbGreen, for example) or the system color constants (vbWindowBackground, for example) or the RGB function to specify border colors.
Note When BorderStyle is set to 0 (Transparent), the BorderColor property is ignored.
For More Information See "Color Constants" for a list of Visual Basic color constants. See "RGB Function" for information on specifying RGB colors. Also, refer to "Working with Text and Graphics" for detailed information on creating graphics in Visual Basic.
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 can't move a line segment using the Move method.
You can use the line control to draw simple lines on forms.
To draw a line on a form
When the pointer moves onto the form, it changes to a cross hair.