ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / Layout Class / DeleteElements Method / DeleteElements(Func<Element,Boolean>) Method
Represents the method that defines a set of criteria and determines whether the specified object meets those criteria.
Example Version

DeleteElements(Func<Element,Boolean>) Method
Deletes an array of elements on a page layout. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public void DeleteElements( 
   Func<Element,bool> predicate
)

Parameters

predicate
Represents the method that defines a set of criteria and determines whether the specified object meets those criteria.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Example
Layout_DeleteElements
//Delete multiple layout elements.

//Perform on the worker thread
await QueuedTask.Run(() =>
{
  layout.DeleteElements(item => item.Name.Contains("Clone"));
});
Delete Layout Elements
//on the QueuedTask  
var elementsToRemove = layout.GetSelectedElements();
layout.DeleteElements(elementsToRemove);
Delete an element or elements on a layout
//Delete an element or elements on a layout.

//Perform on the worker thread
QueuedTask.Run(() =>
{
  //Delete a specific element on a layout
  aLayout.DeleteElement(elm);
 
  //Or delete a group of elements using a filter
  aLayout.DeleteElements(item => item.Name.Contains("Clone"));

  //Or delete all elements on a layout
  aLayout.DeleteElements(item => true);
});
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also