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
)
參數
parent
類型:Microsoft.VisualBasic.PowerPacks.ShapeContainer將要包含 RectangleShape 的 ShapeContainer。
備註
RectangleShape 控制項直接在表單或容器控制項無法顯示;必須在 ShapeContainer 包含它的物件。 在初始化 RectangleShape後,您必須將其 Parent 屬性加入至現有的 ShapeContainer 或 ShapeContainer的新執行個體。
當您將 RectangleShape 加入至已經包含 ShapeContainer的表單或容器時,必須使用現有的 ShapeContainer 而非宣告新的物件。 裝載多個表單或容器的 ShapeContainer 可能會造成與疊置順序和事件中產生未預期的結果。
範例
下列範例建立 RectangleShape 並將它加入至已經包含 LineShape的表單。 這個範例要求您的表單必須有一個名為 LineShape1 的 LineShape 。
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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
Line 和 Shape 控制項簡介 (Visual Studio)