共用方式為


ShapeCollection.Contains 方法

決定是否指定Shape成員的集合。

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

語法

'宣告
Public Function Contains ( _
    value As Shape _
) As Boolean
public bool Contains(
    Shape value
)
public:
bool Contains(
    Shape^ value
)
member Contains : 
        value:Shape -> bool 
public function Contains(
    value : Shape
) : boolean

參數

傳回值

型別:System.Boolean
如果 Shape 是集合的成員,則為 true,否則為 false。

備註

這個方法可讓您判斷是否Shape是集合的成員,嘗試進行運算之前, Shape。可以使用這個方法來確定 Shape 已經加入集合或仍然是集合的成員。

範例

下列範例會示範如何使用Contains方法以移除Shape表單的表單的成員後,才從ShapeCollection。這個範例要求您必須至少兩個OvalShape在表單上的控制項。

    Private Sub Form1_Click() Handles Me.Click
        Dim canvas As ShapeContainer
        ' Get the ShapeContainer.
        canvas = OvalShape1.Parent
        ' If OvalShape2 is in the same collection, remove it.
        If canvas.Shapes.Contains(OvalShape2) Then
            canvas.Shapes.Remove(OvalShape2)
        End If
    End Sub

        private void form1_Click(object sender, System.EventArgs e)
        {
            ShapeContainer canvas;
            // Get the ShapeContainer.
            canvas = ovalShape1.Parent;
            // If OvalShape2 is in the same collection, remove it.
            if (canvas.Shapes.Contains(ovalShape2))
            {
                canvas.Shapes.Remove(ovalShape2);
            }
        }

.NET Framework 安全性

請參閱

參考

ShapeCollection 類別

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

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

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

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