Compartilhar 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

'Declaration
Public Sub New ( _
    left As Integer, _
    top As Integer, _
    width As Integer, _
    height As Integer _
)
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 function RectangleShape(
    left : int, 
    top : int, 
    width : int, 
    height : int
)

Parameters

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 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
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;
}

.NET Framework Security

See Also

Reference

RectangleShape Class

RectangleShape Overload

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

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)