ShapeContainer.Shapes 屬性
取得包含在 ShapeContainer 中的圖案集合。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
<BrowsableAttribute(False)> _
Public ReadOnly Property Shapes As ShapeCollection
[BrowsableAttribute(false)]
public ShapeCollection Shapes { get; }
[BrowsableAttribute(false)]
public:
property ShapeCollection^ Shapes {
ShapeCollection^ get ();
}
[<BrowsableAttribute(false)>]
member Shapes : ShapeCollection with get
function get Shapes () : ShapeCollection
屬性值
類型:Microsoft.VisualBasic.PowerPacks.ShapeCollection
ShapeCollection ,表示 ShapeContainer 中所包含之圖案的集合。
備註
ShapeCollection 為父代圖案的集合。 例如,在中,當多個圖案加入至 Form時,每個圖案是由 ShapeCollection 所指定的成員為表單的 ShapeContainer 。
您可以在 ShapeCollection 指定的圖案搭配使用到 ShapeContainer 使用方法可用的 ShapeCollection 類別。
當您加入數個形狀到 ShapeContainer時,我們建議您在初始化要加入的圖案之前呼叫 SuspendLayout 方法。 在您將圖形加入至 ShapeContainer之後,呼叫 ResumeLayout 方法。 使用 SuspendLayout 和 ResumeLayout 會將有許多圖形應用程式的效能。
範例
下列範例會從表單的 ShapeCollection 移除 Shape (由 Shapes 屬性表示)),如果它是集合的成員。 這個範例要求您具有 LineShape、 OvalShape和 RectangleShape 控制項在表單中。 按下形狀時,會從 ShapeCollection 中移除,除非是在集合的最後一個圖案。
Private Sub Shapes_Click(
ByVal sender As System.Object,
ByVal e As System.EventArgs
) Handles RectangleShape1.Click,
OvalShape1.Click, LineShape1.Click
' Determine whether the shape is in the collection.
If ShapeContainer1.Shapes.Contains(sender) Then
' If the index is greater than 0, remove the shape.
If ShapeContainer1.Shapes.IndexOf(sender) > 0 Then
ShapeContainer1.Shapes.Remove(sender)
End If
End If
End Sub
private void Shapes_Click(System.Object sender, System.EventArgs e)
{
// Determine whether the shape is in the collection.
if (shapeContainer1.Shapes.Contains((Shape) sender))
// If the index is greater than 0, remove the shape.
{
if (shapeContainer1.Shapes.IndexOf((Shape)sender) > 0)
{
shapeContainer1.Shapes.Remove((Shape)sender);
}
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
Line 和 Shape 控制項簡介 (Visual Studio)