ShapeCollection.AddRange Method
Adds an array of Shape objects to the ShapeCollection.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'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[]
)
Parameters
- shapes
Type: array<Microsoft.VisualBasic.PowerPacks.Shape[]
An array of Shape objects to add to the collection.
Remarks
The Shape objects that are contained in the shapes array are added to the end of the collection.
You can use the AddRange method to quickly add a group of Shape objects to the collection. This is faster than manually adding each Shape to the collection by using the Add method.
To remove a Shape that you previously added, use the Remove, RemoveAt, or Clear method.
Notes to Inheritors
When overriding AddRange in a derived class, be sure to call the AddRange method of the base class to guarantee that the shapes are added to the collection.
Examples
The following example adds a group of OvalShape controls to the ShapeCollection of a form. The example requires that you have a RectangleShape control on a form.
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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.VisualBasic.PowerPacks Namespace
Other Resources
Introduction to the Line and Shape Controls (Visual Studio)
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)