ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GraphicsLayerExtensions Class / SelectElement Method
The graphics layer being extended
The element to select. Cannot be null
Example

In This Topic
    SelectElement Method (GraphicsLayerExtensions)
    In This Topic
    Select the element within the GraphicsLayer collection. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public static void SelectElement( 
       GraphicsLayer graphicsLayer,
       Element element
    )
    Public Shared Sub SelectElement( _
       ByVal graphicsLayer As GraphicsLayer, _
       ByVal element As Element _
    ) 

    Parameters

    graphicsLayer
    The graphics layer being extended
    element
    The element to select. Cannot be null
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Value cannot be null: element
    Remarks
    The map view displaying the graphics layer should be initialized.
    Example
    Select Graphic Elements
    var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                        .OfType<ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault();
    if (graphicsLayer == null)
      return;
    var elements = graphicsLayer.GetElementsAsFlattenedList()
                        .Where(e => e.Name.StartsWith("Text"));
    QueuedTask.Run(() =>
    {
      graphicsLayer.SelectElements(elements);
      //or select one element
      graphicsLayer.SelectElement(elements.FirstOrDefault());
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also