Método ShapeCollection.AddRange

Adiciona uma matriz de Shape objetos para o ShapeCollection.

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

Sintaxe

'Declaração
Public Sub AddRange ( _
    shapes As Shape() _
)
public void AddRange(
    Shape[] shapes
)
public:
void AddRange(
    array<Shape^>^ shapes
)
member AddRange : 
        shapes:Shape[] -> unit 
public function AddRange(
    shapes : Shape[]
)

Parâmetros

Comentários

O Shape objetos que estão contidos no shapes matriz são adicionados ao final da coleção.

Você pode usar o AddRange método para adicionar rapidamente um grupo de Shape objetos à coleção.Isso é mais rápido do que adicionar manualmente cada Shape à coleção usando o Add método.

Para remover um Shape que você adicionou anteriormente, use o Remove, RemoveAt, ou Clear método.

Observações para herdeiros

Ao substituir AddRange em uma classe derivada, certifique-se de chamar o AddRange método da classe base para garantir que as formas são adicionadas à coleção.

Exemplos

O exemplo a seguir adiciona um grupo de OvalShape os controles para o ShapeCollection de um formulário.O exemplo requer que você tenha um RectangleShape controle em um formulário.

Private Sub RectangleShape1_Click() Handles RectangleShape1.Click
    ' Create two oval shapes to add to the form.
    Dim oval1 As OvalShape = New OvalShape()
    Dim oval2 As OvalShape = New OvalShape()

    ' Set the size of the ovals.
    oval1.Size = New Size(100, 200)
    oval2.Size = oval1.Size

    ' Set the appropriate location of ovals.
    oval1.Location = New Point(10, 10)
    oval2.Location = New Point(oval1.Left + 10, oval1.Top + 10)

    ' Add the controls to the form by using the AddRange method.
    RectangleShape1.Parent.Shapes.AddRange(New Shape() {oval1, oval2})
End Sub
private void rectangleShape1_Click(System.Object sender, System.EventArgs e)
{
    // Create two oval shapes to add to the form.
    OvalShape oval1 = new OvalShape();
    OvalShape oval2 = new OvalShape();

    // Set the size of the ovals.
    oval1.Size = new Size(100, 200);
    oval2.Size = oval1.Size;

    // Set the appropriate location of ovals.
    oval1.Location = new Point(10, 10);
    oval2.Location = new Point(oval1.Left + 10, oval1.Top + 10);

    // Add the controls to the form by using the AddRange method.
    rectangleShape1.Parent.Shapes.AddRange(new Shape[] { oval1, oval2 });
}

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