ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GraphicsLayerExtensions Class / BringForward Method / BringForward(GraphicsLayer,IEnumerable<Element>) Method
The elements to bring forward
Example

In This Topic
    BringForward(GraphicsLayer,IEnumerable<Element>) Method
    In This Topic
    Bring the elements forward within their parent's element collection. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public static void BringForward( 
       GraphicsLayer graphicsLayer,
       IEnumerable<Element> elements
    )
    Public Overloads Shared Sub BringForward( _
       ByVal graphicsLayer As GraphicsLayer, _
       ByVal elements As IEnumerable(Of Element) _
    ) 

    Parameters

    graphicsLayer
    elements
    The elements to bring forward
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    elements cannot be null or empty
    elements must belong to graphicsLayer
    element parents must be the same and non-null
    Remarks
    Refer to CanBringForward(GraphicsLayer,IEnumerable<Element>) to check whether the elements can be brought forward. Element z order can only be changed relative to their parent's element collection. All elements must have the same parent. The top element will have a z order of N - 1 where N is equal to the number of elements within the element parent's element collection. Check individual element z order with ArcGIS.Desktop.Layouts.Element.ZOrder.
    The map view displaying the graphics layer should be initialized.
    Example
    Ordering: Send backward and Bring forward
    //On the QueuedTask
    //get the current selection set
    var sel_elems = graphicsLayer.GetSelectedElements();
    //can they be brought forward? This will also check that all elements have the same parent
    if (graphicsLayer.CanBringForward(sel_elems))
    {
      //bring forward
      graphicsLayer.BringForward(sel_elems);
      //bring to front (of parent)
      //graphicsLayer.BringToFront(sel_elems);
    }
    else if (graphicsLayer.CanSendBackward(sel_elems))
    {
      //send back
      graphicsLayer.SendBackward(sel_elems);
      //send to the back (of parent)
      //graphicsLayer.SendToBack(sel_elems);
    }
    Ordering: Send backward and Bring forward
    //On the QueuedTask
    //get the current selection set
    var sel_elems = graphicsLayer.GetSelectedElements();
    //can they be brought forward? This will also check that all elements have the same parent
    if (graphicsLayer.CanBringForward(sel_elems))
    {
      //bring forward
      graphicsLayer.BringForward(sel_elems);
      //bring to front (of parent)
      //graphicsLayer.BringToFront(sel_elems);
    }
    else if (graphicsLayer.CanSendBackward(sel_elems))
    {
      //send back
      graphicsLayer.SendBackward(sel_elems);
      //send to the back (of parent)
      //graphicsLayer.SendToBack(sel_elems);
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also