ShapeCollection.AddRange-Methode
Fügt der ShapeCollection ein Array von Shape-Objekten 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
shapes
Typ: array<Microsoft.VisualBasic.PowerPacks.Shape[]Ein Array von Shape-Objekten, die der Auflistung hinzugefügt werden sollen.
Hinweise
Die Objekte Shape, die shapes im Array enthalten sind, werden am Ende der Auflistung hinzugefügt.
Sie können die AddRange-Methode verwenden, um eine Gruppe Objekte zur Shape-Auflistung schnell hinzuzufügen. Dies geht schneller als jedem Shape in die Auflistung manuell, hinzufügen, indem die Add-Methode.
Um Shape entfernen, dem zuvor hinzugefügten, Remove, RemoveAt oder Clear-Methode verwenden.
Hinweise zur Vererbung
Wenn Sie AddRange in einer abgeleiteten Klasse überschreiben, stellen Sie sicher, die AddRange-Methode der Basisklasse aufrufen, um sicherzustellen, dass die Formen zur Auflistung hinzugefügt werden.
Beispiele
Im folgenden Beispiel wird einer Gruppe OvalShape-Steuerelemente ShapeCollection eines Formulars hinzu. Das Beispiel erfordert, dass Sie ein RectangleShape-Steuerelement auf ein 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
- Volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden. Weitere Informationen finden Sie unter Verwenden von Bibliotheken aus teilweise vertrauenswürdigem Code.
Siehe auch
Referenz
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)