[GIS] Unselecting Individual Selected Features using ArcObjects

arcobjectscselect

In my Add-In built using .NET ArcObjects/C# with Arc 10.0 I would like to be able to programmatically unselect a subset of all selected features gathered through a reference to FocusMap.FeatureSelection. I can pretty easily holistically unselect all of the features using the Clear() method, but I need to do this on a more targeted basis. For example, I display a list of all selected features (obtained by casting the FeatureSelection ISelection to an IEnumFeature) to the user and ideally would like to be able to provide some management (read: removal) of the selected features to the user.

So, in a nutshell: Is there a way to remove just a certain feature or features from an entire selection in ArcMap using ArcObjects and if so, what is the preferred method?

Best Answer

You can use the IFeatureSelection::SelectionSet property to return an ISelectionSet. This has the RemoveList method, where you can supply a list of OIDs to be removed from the selection set.

Related Question