Back to Devexpress

ShapeCollection.GetShapesByName(String) Method

officefileapi-devexpress-dot-spreadsheet-dot-shapecollection-dot-getshapesbyname-x28-system-dot-string-x29.md

latest3.5 KB
Original Source

ShapeCollection.GetShapesByName(String) Method

Gets a drawing object(s) by name.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
IList<Shape> GetShapesByName(
    string shapeName
)
vb
Function GetShapesByName(
    shapeName As String
) As IList(Of Shape)

Parameters

NameTypeDescription
shapeNameString

A string that is the name of a drawing object.

|

Returns

TypeDescription
IList<Shape>

A collection of drawing objects with the same name.

|

Remarks

A drawing object name is specified by the Shape.Name property. A worksheet may contain more than one drawing object with the same name. In this situation, the IList<T><Shape,> collection returned by the GetShapesByName method contains several items.

If a drawing object with the specified name is not found, the method returns an empty list.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetShapesByName(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/ShapeActions.cs#L41

csharp
// Find the shape by its name. The method returns a collection of shapes with the same name.
Shape picShape = worksheet.Shapes.GetShapesByName("Picture 4")[0];
picShape.Delete();

wpf-spreadsheetcontrol-api-part-2/VB/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/ShapeActions.vb#L42

vb
' Find the shape by its name. The method returns a collection of shapes with the same name.
Dim picShape As Shape = worksheet.Shapes.GetShapesByName("Picture 4")(0)
picShape.Delete()

See Also

Name

ShapeCollection Interface

ShapeCollection Members

DevExpress.Spreadsheet Namespace