Export (0) Print
Expand All

RectangleShape Constructor (ShapeContainer)

Initializes a new instance of the RectangleShape class, specifying the ShapeContainer that will contain it.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

public RectangleShape(
	ShapeContainer parent
)

A RectangleShape control cannot be displayed directly on a form or container control; it must be contained in a ShapeContainer object. After you initialize a RectangleShape, you will have to set its Parent property either to an existing ShapeContainer or to a new instance of ShapeContainer.

When you add a RectangleShape to a form or container that already contains a ShapeContainer, you should use the existing ShapeContainer instead of declaring a new one. Hosting more than one ShapeContainer on a form or container can cause unexpected results with z-order and events.

The following example creates a RectangleShape and adds it to a form that already contains a LineShape. This example requires that you have a LineShape named LineShape1 on a form.

private void DrawRectangle2()
{
    // Declare a RectangleShape and parent it to  
    // lineShape1's ShapeContainer.
    Microsoft.VisualBasic.PowerPacks.RectangleShape rect1 = 
        new Microsoft.VisualBasic.PowerPacks.RectangleShape(lineShape1.Parent);
    // Set the location and size of the rectangle.
    rect1.Left = 40;
    rect1.Top = 40;
    rect1.Width = 120;
    rect1.Height = 220;
}

Show:
© 2014 Microsoft