ShapeCollection.AddRange-Methode

Fügt ein Array ShapeShapeCollectionObjekte hinzu.

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

Syntax

'Declaration
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[]
)

Parameter

Hinweise

Die Shape-Objekte, die im shapes Array enthalten sind, werden am Ende der Auflistung hinzugefügt.

Sie können die AddRange-Methode können Sie eine Gruppe Shape-Objekte schnell zur Auflistung hinzuzufügen.Dies ist schneller als der Auflistung hinzugefügt werden Shape manuell, mithilfe der Add-Methode.

So entfernen Shape , den Sie vorher hinzugefügt haben, Remove, RemoveAtoder Clear-Methode verwenden.

Hinweise zur Vererbung

Wenn Sie AddRange in einer abgeleiteten Klasse überschreiben, müssen Sie unbedingt die AddRange-Methode der Basisklasse aufrufen, um sicherzustellen, dass die Formen der Auflistung hinzugefügt werden sollen.

Beispiele

Im folgenden Beispiel wird eine Gruppe OvalShape-Steuerelemente ShapeCollection eines Formulars hinzu.Für dieses Beispiel ist es erforderlich, dass Sie ein RectangleShape-Steuerelement in einem Formular verfügen.

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

.NET Framework-Sicherheit

Siehe auch

Referenz

ShapeCollection Klasse

Microsoft.VisualBasic.PowerPacks-Namespace

Weitere Ressourcen

Einführung in das Line-Steuerelement und das Shape-Steuerelement (Visual Studio)

Gewusst wie: Zeichnen von Linien mit dem LineShape-Steuerelement (Visual Studio)

Gewusst wie: Zeichnen von Formen mit dem OvalShape-Steuerelement und dem RectangleShape-Steuerelement (Visual Studio)