Método ShapeCollection.RemoveAt

Remove um Shape da ShapeCollection no local especificado indexados local.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (em Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintaxe

'Declaração
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

Implementações

IList.RemoveAt(Int32)

Comentários

Quando um Shape é removido da coleção de controle, todas as formas subseqüentes são movidas para cima uma posição na coleção.

Você também pode remover um Shape usando o Remove método ou remover todas as formas usando o Clear método.

Para adicionar novos Shape objetos à coleção, use o Add ou AddRange método.

Exemplos

O exemplo a seguir demonstra como usar o RemoveAt método para remover um Shape de um formulário se ele fizer parte do formulário ShapeCollection.Este exemplo requer que você tenha pelo menos duas OvalShape controles em um formulário.

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

Segurança do .NET Framework

Consulte também

Referência

ShapeCollection Classe

Namespace Microsoft.VisualBasic.PowerPacks

Outros recursos

Introdução à linha e controles Shape (Visual Studio)

Como: desenhar linhas com o controle de LineShape (Visual Studio)

Como: desenhar formas com os controles de RectangleShape (Visual Studio) e o OvalShape