共用方式為


RectangleShape 建構函式 (ShapeContainer)

初始化新的執行個體的RectangleShape類別,指定ShapeContainer ,當中會包含它。

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

語法

'宣告
Public Sub New ( _
    parent As ShapeContainer _
)
public RectangleShape(
    ShapeContainer parent
)
public:
RectangleShape(
    ShapeContainer^ parent
)
new : 
        parent:ShapeContainer -> RectangleShape
public function RectangleShape(
    parent : ShapeContainer
)

參數

備註

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

當您新增RectangleShape至表單或容器已經包含ShapeContainer,您應該使用現有的ShapeContainer而不是宣告一個新。裝載多個ShapeContainer在表單或容器可能會造成未預期的結果與疊置順序和事件。

範例

下列範例會建立RectangleShape ,並將它加入至已經包含表單的LineShape。這個範例要求您必須LineShape的表單上命名為 LineShape1。

Private Sub DrawRectangle2()
    ' Declare a RectangleShape and parent it to 
    ' LineShape1's ShapeContainer.
    Dim rect1 As New Microsoft.VisualBasic.PowerPacks.
        RectangleShape(LineShape1.Parent)
    ' Set the location and size of the rectangle.
    rect1.Left = 40
    rect1.Top = 40
    rect1.Width = 120
    rect1.Height = 220
End Sub
private void DrawRectangle2()
{
    // Declare a RectangleShape and parent it to 
    // lineShape1's ShapeContainer.
    Microsoft.VisualBasic.PowerPacks.RectangleShape rect1 = 
        new Microsoft.VisualBasic.PowerPacks.RectangleShape(lineShape1.Parent);
    // Set the location and size of the rectangle.
    rect1.Left = 40;
    rect1.Top = 40;
    rect1.Width = 120;
    rect1.Height = 220;
}

.NET Framework 安全性

請參閱

參考

RectangleShape 類別

RectangleShape 多載

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

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

HOW TO:使用 LineShape 控制項繪製線條 (Visual Studio)

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