ShapeCollection.Remove Method (Shape)
Removes the specified Shape from the ShapeCollection.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
public void Remove(
Shape value
)
public:
void Remove(
Shape^ value
)
member Remove :
value:Shape -> unit
Public Sub Remove (
value As Shape
)
Parameters
value
Type: Microsoft.VisualBasic.PowerPacks.ShapeThe Shape to remove from the ShapeCollection.
Remarks
When a Shape is removed from the control collection, all subsequent shapes are moved up one position in the collection.
You can also remove a Shape by using the RemoveAt method, or remove all shapes by using the Clear method.
To add new Shape objects to the collection, use the Add or AddRange method.
Notes to Inheritors:
When overriding Remove in a derived class, be sure to call the Remove method of the base class to guarantee that the shape is removed from the collection.
Examples
The following example demonstrates how to use the Remove method to remove a Shape from a form if it is a member of the form's ShapeCollection. This example requires that you have at least two OvalShape controls on a form.
private void form1_Click(object sender, System.EventArgs e)
{
ShapeContainer canvas;
// Get the ShapeContainer.
canvas = ovalShape1.Parent;
// If OvalShape2 is in the same collection, remove it.
if (canvas.Shapes.Contains(ovalShape2))
{
canvas.Shapes.Remove(ovalShape2);
}
}
Private Sub Form1_Click() Handles Me.Click
Dim canvas As ShapeContainer
' Get the ShapeContainer.
canvas = OvalShape1.Parent
' If OvalShape2 is in the same collection, remove it.
If canvas.Shapes.Contains(OvalShape2) Then
canvas.Shapes.Remove(OvalShape2)
End If
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