ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / LayoutView Class / SelectElements Method / SelectElements(IReadOnlyList<Element>) Method
A list of existing layout elements.
Example

In This Topic
    SelectElements(IReadOnlyList<Element>) Method
    In This Topic
    Set the selected layout elements for the layout view. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overloads Sub SelectElements( _
       ByVal elements As IReadOnlyList(Of Element) _
    ) 
    public void SelectElements( 
       IReadOnlyList<Element> elements
    )

    Parameters

    elements
    A list of existing layout elements.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    elements must belong to layout 'URI'
    Example
    Set element selection
    {
      //Set the active layout view's selection to include 2 rectangle elements.
    
      //Reference the active view 
      LayoutView activeLayoutView = LayoutView.Active;
      if (activeLayoutView != null)
      {
        //Note: Must be on QueuedTask.Run
        //Reference the layout
        Layout lyt = activeLayoutView.Layout;
    
        //Reference the two rectangle elements
        Element rec = lyt.FindElement("Rectangle");
        Element rec2 = lyt.FindElement("Rectangle 2");
    
        //Construct a list and add the elements
        List<Element> elmList = new List<Element>
        {
          rec,
          rec2
        };
        //Set the selection
        activeLayoutView.SelectElements(elmList);
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also