ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GraphicsLayerExtensions Class / SelectElements Method
The graphics layer being extended
The elements to select. If null then all elements are selected
Example

In This Topic
    SelectElements Method (GraphicsLayerExtensions)
    In This Topic
    Select the elements within the GraphicsLayer collection. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Shared Sub SelectElements( _
       ByVal graphicsLayer As GraphicsLayer, _
       Optional ByVal elements As IEnumerable(Of Element) _
    ) 
    public static void SelectElements( 
       GraphicsLayer graphicsLayer,
       IEnumerable<Element> elements
    )

    Parameters

    graphicsLayer
    The graphics layer being extended
    elements
    The elements to select. If null then all elements are selected
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    If a child of a group element is provided in the list of elements to be selected in addition to its parent then the parent is the element selected.
    The map view displaying the graphics layer should be initialized.
    Example
    Select Graphic Elements
    {
      var elements = graphicsLayer.GetElementsAsFlattenedList()
                          .Where(e => e.Name.StartsWith("Text"));
      // Note: must be called on the QueuedTask
      {
        graphicsLayer.SelectElements(elements);
        //or select one element
        graphicsLayer.SelectElement(elements.FirstOrDefault());
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also