RectangleShape Constructor (Int32, Int32, Int32, Int32)

 

Initializes a new instance of the RectangleShape class, specifying its location and size.

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

public RectangleShape(
	int left,
	int top,
	int width,
	int height
)

Parameters

x

An Integer representing the left edge (in pixels) of the RectangleShape.

y

An Integer representing the top edge (in pixels) of the RectangleShape.

width
Type: System.Int32

An Integer representing the width (in pixels) of the RectangleShape.

height
Type: System.Int32

An Integer representing the height (in pixels) of the RectangleShape.

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.

The following example creates a ShapeContainer and a RectangleShape, adds them to a form, and displays a 90 pixel by 90 pixel square.

private void DrawSquare()
{
    Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas = 
        new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
    // Declare a RectangleShape and set the location and size.
    Microsoft.VisualBasic.PowerPacks.RectangleShape rect1 = 
        new Microsoft.VisualBasic.PowerPacks.RectangleShape(15, 15, 105, 105);
    // Set the form as the parent of the ShapeContainer.
    canvas.Parent = this;
    // Set the ShapeContainer as the parent of the RectangleShape.
    rect1.Parent = canvas;
}
Return to top
Show: