共用方式為


ShapeCollection.RemoveAt 方法

移除ShapeShapeCollection在指定索引位置。

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

語法

'宣告
Public Sub RemoveAt ( _
    index As Integer _
)
public void RemoveAt(
    int index
)
public:
virtual void RemoveAt(
    int index
) sealed
abstract RemoveAt : 
        index:int -> unit 
override RemoveAt : 
        index:int -> unit 
public final function RemoveAt(
    index : int
)

參數

實作

IList.RemoveAt(Int32)

備註

Shape會移除從控制項集合中,後續的所有圖形都會在集合中的一個位置往上都移。

您也可以移除Shape藉由使用Remove方法或使用的所有圖案的移除Clear方法。

若要加入新Shape物件加入集合中,使用AddAddRange方法。

範例

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

Private Sub OvalShape2_Click() Handles OvalShape2.Click
    Dim i As Integer
    ' Find the index for OvalShape1.
    i = OvalShape2.Parent.Shapes.GetChildIndex(OvalShape1, False)
    ' If the shape is not in the collection, display a message.
    If i = -1 Then
        MsgBox("OvalShape1 is not in this collection.")
    Else
        ' Remove the shape.
        OvalShape2.Parent.Shapes.RemoveAt(i)
    End If
End Sub
private void ovalShape2_Click(System.Object sender, System.EventArgs e)
{
    int i;
    // Find the index for OvalShape1.
    i = ovalShape2.Parent.Shapes.GetChildIndex(ovalShape1, false);
    // If the shape is not in the collection, display a message.
    if (i == -1)
    {
        MessageBox.Show("ovalShape1 is not in this collection.");
    }
    else
    {
        // Remove the shape.
        ovalShape2.Parent.Shapes.RemoveAt(i);
    }
}

.NET Framework 安全性

請參閱

參考

ShapeCollection 類別

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

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

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

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