ShapeCollection.RemoveAt (Método)

quita Shape de ShapeCollection en la ubicación indizado especificada.

Espacio de nombres:  Microsoft.VisualBasic.PowerPacks
Ensamblado:  Microsoft.VisualBasic.PowerPacks.Vs (en Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintaxis

'Declaración
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
)

Parámetros

Implementaciones

IList.RemoveAt(Int32)

Comentarios

Cuando Shape se quita de la colección del control, todas las formas subsiguientes se retiran una posición en la colección.

También puede quitar Shape utilizando el método de Remove , quitar todas las formas mediante el método de Clear .

Para agregar nuevos objetos de Shape a la colección, utilice el método de Add o de AddRange .

Ejemplos

El ejemplo siguiente muestra cómo utilizar el método de RemoveAt para quitar Shape de un formulario si es miembro de ShapeCollectiondel formulario.Este ejemplo requiere que tenga al menos dos controles de OvalShape en un formulario.

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);
    }
}

Seguridad de .NET Framework

Vea también

Referencia

ShapeCollection Clase

Microsoft.VisualBasic.PowerPacks (Espacio de nombres)

Otros recursos

Introducción a los controles de líneas y formas (Visual Studio)

Cómo: Dibujar líneas con el control LineShape (Visual Studio)

Cómo: Dibujar formas con los controles OvalShape y RectangleShape (Visual Studio)