ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GraphicsLayerExtensions Class / FindElement Method
The graphics layer being extended
The name of the element to find. Cannot be null
Example

In This Topic
    FindElement Method (GraphicsLayerExtensions)
    In This Topic
    Finds the element recursively with the given name within the GraphicsLayer collection. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public static Element FindElement( 
       GraphicsLayer graphicsLayer,
       string elementName
    )
    Public Shared Function FindElement( _
       ByVal graphicsLayer As GraphicsLayer, _
       ByVal elementName As String _
    ) As Element

    Parameters

    graphicsLayer
    The graphics layer being extended
    elementName
    The name of the element to find. Cannot be null

    Return Value

    The ArcGIS.Desktop.Layouts.Element or null if it is not found
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Value cannot be null: elementName
    Remarks
    Find recurses nested groups to find the given element.
    The map view displaying the graphics layer should be initialized.
    Example
    Modify symbology of a Graphic Element
    //within a queued Task
    //get the first line element in the layer
    var ge = graphicsLayer.FindElement("Line 10") as GraphicElement;
    var graphic = ge.GetGraphic();
    if (graphic is CIMLineGraphic lineGraphic)
    {
      //change its symbol
      lineGraphic.Symbol =
       SymbolFactory.Instance.ConstructLineSymbol(
         SymbolFactory.Instance.ConstructStroke(
     ColorFactory.Instance.BlueRGB, 2, SimpleLineStyle.DashDot)).MakeSymbolReference();
      //apply the change
      ge.SetGraphic(lineGraphic);
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also