Line and Shape Controls in

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

                Line and Shape control of the Power packs in toolbox                          

  1. Drag the LineShape control from the Toolbox drag to a form or container control.
  2. Drag the sizing and move handles to size and position the line.

                                            — —Or—–

       Imports Microsoft.VisualBasic.PowerPacks
        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  

  • amit dahiya

    sir actually i have to select a line that is drawn in 2010 at run time……….

    how i can do this??????????????????????/
    please help me.

  • Hello Amit


    Are you using powerpack for drawing a line at run time?

  • sukirti panu

    yes i m using power pack and line is drawn by me with drawline method also but i m not able to select this at run time.please help me.

  • Coder

    Line can drawn with the help of two very common methods in .net
    a. by using LineShape control of powerpack
    b. By using drawline method of Graphics class.
    you are saying you are using DrawLine method with powerpack…that is not good to hear.
    can you clarify that why does you need to select the line?

  • sukirti

    sir now i have drwan a line and selected also by using lineshape nw m also facing a problem n that is when i go to a selected line ,i am not able to delete can i do this?????

  • sukirti panu

    now i am using lineshape control for drawing a line.i want to select the line at run time for performing zoom,change the color of line,delete the line, can i do it??????plz suggest for this.

  • Dave Morrison

    How do you clear the canvas