public bool RemoveItem( IProjectItem item )
Public Function RemoveItem( _ ByVal item As IProjectItem _ ) As Boolean
Parameters
- item
- The IProjectItem to be removed
Return Value
Returns a boolean indicating the operation's success.
public bool RemoveItem( IProjectItem item )
Public Function RemoveItem( _ ByVal item As IProjectItem _ ) As Boolean
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
/// Remove a folder connection from a project; the folder stored on the local disk /// or the network is not deleted FolderConnectionProjectItem folderToRemove = Project.Current.GetItems<FolderConnectionProjectItem>().FirstOrDefault(folder => folder.Name.Equals("PlantSpecies")); if (folderToRemove != null) Project.Current.RemoveItem(folderToRemove as IProjectItem);
/// Remove a map from a project; the map is deleted IProjectItem mapToRemove = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(map => map.Name.Equals("OldStreetRoutes")); var removedMapProjectItem = await QueuedTask.Run( () => Project.Current.RemoveItem(mapToRemove));
// Remove a folder connection from a project; the folder stored on the local disk or the network is not deleted FolderConnectionProjectItem folderToRemove = Project.Current.GetItems<FolderConnectionProjectItem>().FirstOrDefault(myfolder => myfolder.Name.Equals("PlantSpecies")); if (folderToRemove != null) Project.Current.RemoveItem(folderToRemove as IProjectItem);
//This example deletes a layout in a project after finding it by name. //Added references using ArcGIS.Desktop.Core; using ArcGIS.Desktop.Layouts; public class DeleteLayoutExample { public static Task<bool> DeleteLayoutAsync(string LayoutName) { //Reference a layoutitem in a project by name LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName)); //Check for layoutItem if (layoutItem == null) return Task.FromResult<bool>(false); //Delete the layout from the project return Task.FromResult<bool>(Project.Current.RemoveItem(layoutItem)); } }
//Remove a layout project item. //Remove the layout fro the project await QueuedTask.Run(() => Project.Current.RemoveItem(layoutItem));
//Note: Call within QueuedTask.Run() //Reference a reportitem in a project by name ReportProjectItem reportItem = Project.Current.GetItems<ReportProjectItem>().FirstOrDefault(item => item.Name.Equals(reportName)); //Check for report item if (reportItem == null) return Task.FromResult<bool>(false); //Delete the report from the project return Task.FromResult<bool>(Project.Current.RemoveItem(reportItem));
Target Platforms: Windows 11, Windows 10