ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Layout Class / DeleteElement Method
Element
Example

In This Topic
    DeleteElement Method (Layout)
    In This Topic
    Deletes an element on a page layout. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Sub DeleteElement( _
       ByVal element As Element _
    ) 
    public void DeleteElement( 
       Element element
    )

    Parameters

    element
    Element
    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run.
    Example
    Delete an element or elements on a layout
    {
      //Delete an element or elements on a layout.
      //Note: Must be on QueuedTask.Run
    
      //Delete a specific element on a layout
      //Find a single specific element
      Element rect = layout.FindElement("Rectangle") as Element;
      layout.DeleteElement(rect);
    
      //Or delete a group of elements using a filter
      layout.DeleteElements(item => item.Name.Contains("Clone"));
    
      //Or delete all elements on a layout
      layout.DeleteElements(item => true);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also