ShapeCollection.Clear Method
Removes all shapes from the collection.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'Declaration
Public Sub Clear
'Usage
Dim instance As ShapeCollection
instance.Clear()
public void Clear()
public:
virtual void Clear() sealed
public final function Clear()
Implements
Remarks
You can use the Clear method to remove the whole collection of shapes from a ShapeContainer.
To remove an individual shape from the collection, use the Remove or RemoveAt method.
To add new Shape objects to the collection, use the Add or AddRange method.
Notes to Inheritors:
When overriding Clear in a derived class, be sure to call the Clear method of the base class to guarantee that all the shapes are removed from the collection.
Examples
The following example demonstrates how to use the Clear method to remove the whole collection of shapes from a parent container. This example requires that you have at least two OvalShape controls on a form.
Private Sub Form1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Click
' Call the method to remove the shapes.
RemoveShapes(OvalShape1)
End Sub
Private Sub RemoveShapes(ByVal shape As Shape)
Dim canvas As ShapeContainer
' Find the ShapeContainer in which the shape is located.
canvas = shape.Parent
' Call the Clear method to remove all shapes.
canvas.Shapes.Clear()
End Sub
private void form1_Click(object sender, System.EventArgs e)
{
// Call the method to remove the shapes.
RemoveShapes(ovalShape1);
}
private void RemoveShapes(Shape shape)
{
ShapeContainer canvas;
// Find the ShapeContainer in which the shape is located.
canvas = shape.Parent;
// Call the Clear method to remove all shapes.
canvas.Shapes.Clear();
}
.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)