ShapeCollection.Add Method (Shape)
Adds the specified Shape to the ShapeCollection.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
public void Add(
Shape value
)
public:
void Add(
Shape^ value
)
member Add :
value:Shape -> unit
Public Sub Add (
value As Shape
)
Parameters
value
Type: Microsoft.VisualBasic.PowerPacks.ShapeThe Shape to add to the ShapeCollection.
Remarks
The Add method enables you to add Shape objects to the end of a ShapeCollection.
You can also add new Shape objects to the collection by using the AddRange method.
To remove a Shape that you previously added, use the Remove, RemoveAt, or Clear method.
Notes to Inheritors:
When overriding Add in a derived class, be sure to call the Add method of the base class to guarantee that the Shape is added to the ShapeCollection.
Examples
The following example adds a new Shape to the ShapeCollection of a form. This example requires that you have a RectangleShape control on a form.
private void rectangleShape1_Click(System.Object sender, System.EventArgs e)
{
// Declare a new oval shape to add to the form.
OvalShape oval = new OvalShape();
// Add the oval shape to the form.
rectangleShape1.Parent.Shapes.Add(oval);
oval.Location = new Point(50, 50);
oval.Size = new Size(200, 100);
}
Private Sub RectangleShape1_Click() Handles RectangleShape1.Click
' Declare a new oval shape to add to the form.
Dim oval As OvalShape = New OvalShape()
' Add the oval shape to the form.
RectangleShape1.Parent.Shapes.Add(oval)
oval.Location = New Point(50, 50)
oval.Size = New Size(200, 100)
End Sub
See Also
ShapeCollection Class
Microsoft.VisualBasic.PowerPacks Namespace
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)
Return to top