ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GraphicsLayerExtensions Class / RemoveElements Method
The graphics layer being extended
The elements being removed
Example

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

    Parameters

    graphicsLayer
    The graphics layer being extended
    elements
    The elements being removed
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    If elements is null then all elements are removed.
    If a group element is provided in the list of elements to be removed then the group element and all its children will be removed.
    If a child of a group element is provided in the list in addition to its parent then the parent takes precedence (i.e. the entire group element is removed and not just that child).
    The map view displaying the graphics layer should be initialized.
    Example
    Remove Graphic elements
    //on the QueuedTask      
    graphicsLayer.RemoveElements(graphicsLayer.GetSelectedElements());
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also