Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Remove a Shape

This example illustrates how to remove a shape.

You can remove an item from the ShapeCollection using the ShapeCollection.RemoveAt method.

worksheet.Shapes.RemoveAt(3);

If a target item is a Chart or Picture object, the ShapeCollection.RemoveAt method call removes this shape from two collections: ShapeCollection and ChartCollection or PictureCollection, respectively.

Call the Shape.Delete method to remove a Shape object directly. The code sample below shows how to remove all connectors from a worksheet.

foreach (Shape shape in worksheet.Shapes)
{
    if (shape.ShapeType == ShapeType.Connector)
        shape.Delete();
}