RectangleShape Class
Represents a control displayed as a square, rectangle, rounded square, or rounded rectangle.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'Declaration
<ToolboxBitmapAttribute(GetType(RectangleShape), "Microsoft.VisualBasic.PowerPacks.RectangleShape.bmp")> _
Public Class RectangleShape _
Inherits SimpleShape
'Usage
Dim instance As RectangleShape
[ToolboxBitmapAttribute(typeof(RectangleShape), "Microsoft.VisualBasic.PowerPacks.RectangleShape.bmp")]
public class RectangleShape : SimpleShape
[ToolboxBitmapAttribute(typeof(RectangleShape), L"Microsoft.VisualBasic.PowerPacks.RectangleShape.bmp")]
public ref class RectangleShape : public SimpleShape
public class RectangleShape extends SimpleShape
Remarks
The RectangleShape control enables you to draw rectangles on a form or container at design time or run time.
When you add a Line or Shape control to a form or container, an invisible ShapeContainer object is created. The ShapeContainer acts as a drawing surface for the shapes within each container control. Each ShapeContainer has a corresponding ShapeCollection that enables you to iterate through the Line and Shape controls that are contained in the ShapeContainer.
When you create a RectangleShape control at run time, you must also create a ShapeContainer and set the Parent property of the RectangleShape to the ShapeContainer.
Examples
The following example creates a ShapeContainer and a RectangleShape, adds them to a form, and displays a rectangle.
Private Sub DrawRectangle()
Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim rect1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape
' Set the form as the parent of the ShapeContainer.
canvas.Parent = Me
' Set the ShapeContainer as the parent of the RectangleShape.
rect1.Parent = canvas
' Set the location and size of the rectangle.
rect1.Left = 10
rect1.Top = 10
rect1.Width = 300
rect1.Height = 100
End Sub
private void DrawRectangle()
{
Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas =
new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
Microsoft.VisualBasic.PowerPacks.RectangleShape rect1 =
new Microsoft.VisualBasic.PowerPacks.RectangleShape();
// Set the form as the parent of the ShapeContainer.
canvas.Parent = this;
// Set the ShapeContainer as the parent of the RectangleShape.
rect1.Parent = canvas;
// Set the location and size of the rectangle.
rect1.Left = 10;
rect1.Top = 10;
rect1.Width = 300;
rect1.Height = 100;
}
Inheritance Hierarchy
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
Microsoft.VisualBasic.PowerPacks.Shape
Microsoft.VisualBasic.PowerPacks.SimpleShape
Microsoft.VisualBasic.PowerPacks.RectangleShape
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
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)