ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Layout Class / GetSelectedElements Method
Example

In This Topic
    GetSelectedElements Method (Layout)
    In This Topic
    Get a collection of the selected layout elements.
    Syntax
    Example
    Delete Layout Elements
    //on the QueuedTask  
    var elementsToRemove = layout.GetSelectedElements();
    layout.DeleteElements(elementsToRemove);
    Group Graphic Elements
    //on the QueuedTask
    var elemsToGroup = layout.GetSelectedElements();
    //Note: run within the QueuedTask
    //group  elements
    var groupElement = layout.GroupElements(elemsToGroup);
    Ordering: Send backward and Bring forward
    //On the QueuedTask
    //get the current selection set
    var sel_elems = layout.GetSelectedElements();
    //can they be brought forward? This will also check that all elements have the same parent
    if (layout.CanBringForward(sel_elems))
    {
      //bring forward
      layout.BringForward(sel_elems);
      //bring to front (of parent)
      //graphicsLayer.BringToFront(sel_elems);
    }
    else if (layout.CanSendBackward(sel_elems))
    {
      //send back
      layout.SendBackward(sel_elems);
      //send to the back (of parent)
      //graphicsLayer.SendToBack(sel_elems);
    }
    Get Z-Order
    var selElementsZOrder = layout.GetSelectedElements();
    //list out the z order
    foreach (var elem in selElementsZOrder)
      //At 2.x - System.Diagnostics.Debug.WriteLine($"{elem.Name}: z-order {elem.GetZOrder()}");
      System.Diagnostics.Debug.WriteLine($"{elem.Name}: z-order {elem.ZOrder}");
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also