ShapeCollection.AddRange, méthode
Ajoute un tableau d'objets Shape au ShapeCollection.
Espace de noms : Microsoft.VisualBasic.PowerPacks
Assembly : Microsoft.VisualBasic.PowerPacks.Vs (dans Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntaxe
'Déclaration
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[]
)
Paramètres
shapes
Type : array<Microsoft.VisualBasic.PowerPacks.Shape[]Tableau d'objets Shape à ajouter à la collection.
Notes
Les objets d'Shape contenus dans le tableau d'shapes sont ajoutés à la fin de la collection.
Vous pouvez utiliser la méthode de AddRange pour ajouter rapidement un groupe d'objets Shape à la collection. Il est plus rapide que vous ajoutez manuellement chaque Shape à la collection à l'aide de la méthode de Add.
Pour supprimer Shape que vous avez ajouté, utilisez Remove, RemoveAt, ou la méthode d'Clear.
Remarques à l'attention des héritiers
En remplaçant AddRange dans une classe dérivée, veillez à appeler la méthode de AddRange de la classe de base pour garantir que les formes sont ajoutées à la collection.
Exemples
L'exemple suivant ajoute un groupe de contrôles d'OvalShape à ShapeCollection d'un formulaire. L'exemple exige que vous avez un contrôle d'RectangleShape sur un formulaire.
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 });
}
Sécurité .NET Framework
- Confiance totale accordée à l'appelant immédiat. Ce membre ne peut pas être utilisé par du code d'un niveau de confiance partiel. Pour plus d'informations, voir Utilisation de bibliothèques à partir de code d'un niveau de confiance partiel.
Voir aussi
Référence
Microsoft.VisualBasic.PowerPacks, espace de noms
Autres ressources
Introduction aux contrôles Line et Shape (Visual Studio)
Comment : dessiner des lignes avec le contrôle LineShape (Visual Studio)
Comment : dessiner des formes avec les contrôles OvalShape et RectangleShape (Visual Studio)