RemoveItem Method (Project)
Removes the project item from the current project. This method must be called on the MCT. Use QueuedTask.Run.
Parameters
- item
- The IProjectItem to be removed
Return Value
Returns a boolean indicating the operation's success.
Remove FolderConnection From Project
/// 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 Map From Project
/// 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 specific folder connection
// 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);
Delete_Layout
//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 a layout project item.
//Remove the layout fro the project
await QueuedTask.Run(() => Project.Current.RemoveItem(layoutItem));
Delete a report
//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
ArcGIS Pro version: 3 or higher.