ShapeCollection.RemoveAt 方法

ShapeCollection 移除 Shape 在指定的索引位置。

命名空间:  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 从控件集合中移除,所有后续形状中移动集合中的某个位置。

使用 Remove 方法,还可以移除 Shape ,使用 Clear 方法,也可以移除所有形状。

若要向集合中添加新的 Shape 对象,请使用 AddAddRange 方法。

示例

,如果它是窗体的 ShapeCollection,的成员下面的示例演示如何使用 RemoveAt 方法从窗体中移除 Shape 。 此示例要求窗体的至少有两个 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)

如何:使用 LineShape 控件绘制直线 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控件绘制形状 (Visual Studio)