Visual Basic Power Packs controls allow us to draw lines, rectangle and oval shapes on your Windows Forms application. These controls accept many of the graphics methods of system. Drawing namespace. This enables you to draw lines and shapes in a single step without having to create graphics objects, pens, and brushes.
We can able to draw horizontal, vertical, and diagonal lines, rectangles, squares, ovals, circles, and rectangles and squares with the help of power pack graphical controls. Now we discuss about and Shape Controls
Introduction to the Line and Shape Controls
The Visual Basic Power Packs Line and Shape controls are a set of three graphical controls that enable you to draw lines and shapes on forms and containers.
LineShape control -is used to draw horizontal, vertical, and diagonal lines.
OvalShape control is used to draw circles and ovals.
RectangleShape control is used to draw rectangles and squares.
Line and Shape Object Model
Line and Shape controls derive from a base Shape class that defines their shared properties, methods, and events.
The following illustration shows the Line and Shape object hierarchy.
Line and Shape object hierarchy
How to Draw Lines with the LineShape Control
- Drag the LineShape control from the Toolbox drag to a form or container control.
- Drag the sizing and move handles to size and position the line.
Dim ShapeCon As New ShapeContainer Dim testLine As New LineShape ShapeCon.Parent = Me testLine.Parent = ShapeCon testLine.StartPoint = New System.Drawing.Point(10, 10) testLine.EndPoint = New System.Drawing.Point(300, 300)
Note: When a Line or Shape control is added to a form or container, an invisible ShapeContainer object is created. The ShapeContainer acts as a canvas for the shapes within each container control