共用方式為


RectangleShape 建構函式 (Int32, Int32, Int32, Int32)

初始化 RectangleShape 類別的新執行個體,並指定其位置和大小。

命名空間:  Microsoft.VisualBasic.PowerPacks
組件:  Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

語法

'宣告
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
)

參數

  • left
    類型:Int32
  • top
    類型:Int32
  • width
    類型:Int32

    Integer,表示 RectangleShape 的寬度 (以像素為單位)。

  • height
    類型:Int32

    Integer,表示 RectangleShape 的高度 (以像素為單位)。

備註

RectangleShape 控制項直接在表單或容器控制項無法顯示;必須在 ShapeContainer 包含它的物件。 在初始化 RectangleShape後,您必須將其 Parent 屬性加入至現有的 ShapeContainerShapeContainer的新執行個體。

範例

下列範例建立 ShapeContainerRectangleShape,將它們加入至表單,並使用 90 像素的方形顯示 90 像素。

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 安全性

請參閱

參考

RectangleShape 類別

RectangleShape 多載

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

Line 和 Shape 控制項簡介 (Visual Studio)

如何:使用 LineShape 控制項繪製線條 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)