Share via


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)

Syntax

public RectangleShape(
    int left,
    int top,
    int width,
    int height
)
public:
RectangleShape(
    int left,
    int top,
    int width,
    int height
)
new : 
        left:int *
        top:int *
        width:int *
        height:int -> RectangleShape
Public Sub New (
    left As Integer,
    top As Integer,
    width As Integer,
    height As Integer
)

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.

Remarks

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.

Examples

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;
}
Private Sub DrawSquare()
    Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
    ' Declare a RectangleShape and set the location and size.
    Dim rect1 As New Microsoft.VisualBasic.PowerPacks.
        RectangleShape(15, 15, 105, 105)
    ' Set the form as the parent of the ShapeContainer.
    canvas.Parent = Me
    ' Set the ShapeContainer as the parent of the RectangleShape.
    rect1.Parent = canvas
End Sub

See Also

RectangleShape Overload
RectangleShape Class
Microsoft.VisualBasic.PowerPacks Namespace
Introduction to the Line and Shape Controls (Visual Studio)
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Return to top