Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
How does the user specify which layer is to have its selection modified, and how do they specify which features to add or remove from the selection? Is this really any better than the built-in selection methods? – blah238 Oct 17 '12 at 19:38
The requested setup was to remove all selections from a given layer such that the user would be presented with a dialog containing all layers that currently have a selection and to remove the entire layer's selection wholesale. – AHigh Oct 17 '12 at 19:43
I am wondering more now whether this is really worthwhile as opposed to relying on the built functionality ESRI provides in ArcMap. – AHigh Oct 17 '12 at 19:46
Also, have you already seen the Custom Selection Extension add-in sample? This doesn't provide exactly what you are looking for but it does contain some of the things you will probably end up needing to implement. – blah238 Oct 17 '12 at 19:50

2 Answers 2

up vote 2 down vote accepted

There are several ways of doing this through ArcObjects but you might also consider using the built-in selection methods such as the selection tab of the table of contents:

Selection Tab

Here you can see the selected feature count for each layer, make each layer selectable or unselectable, and clear each layer's selection individually, which sounds like what you are looking for.

share|improve this answer
I think this is going to be the best bet. The alternative I was trying to come up with really was to explicitly force the user to be conscious of what features they were selecting before proceeding to another operation with them. This built functionality is exactly what I was looking for but puts a little more onus onto the user to be aware of their selections. Sometimes the best solution is the easiest (development wise). – AHigh Oct 17 '12 at 20:00
Yep, this is probably one of those things that you would only know about if you really do a lot of editing or analysis work in ArcMap, so it's good to have that type of user have input on the requirements of any custom tools. – blah238 Oct 17 '12 at 20:06

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.

share|improve this answer
+1 I removed my answer since this is the easiest way to accomplish the task. – Nick O Oct 17 '12 at 19:09
How will this fare across multiple layers/classes where the OID may be duplicated? – AHigh Oct 17 '12 at 19:19
Note that in Java and .NET you will need to use the IGeodatabaseBridge2 AddList or RemoveList methods as the native ISelectionSet equivalents are not interop-safe. – blah238 Oct 17 '12 at 19:27
From the help: "IEnumFeature works on all of the FeatureLayers as a whole. Each FeatureLayer has a ISelectionSet and IEnumFeature steps through all of these as though there was only one. Because IEnumFeature works with all the FeatureLayers, you cannot use it to loop through the features belonging to just one FeatureLayer." In your add-in, do you want the user to remove selected features from a variety of featurelayers? – kenbuja Oct 17 '12 at 19:28
That's the goal. As an example: LayerA is essentially a background layer, say county polygons and LayerB is a polygon layer with some features of interest. Without disabling selection of LayerA I need the user to be able to remove LayerA's selections from this list as warranted. – AHigh Oct 17 '12 at 19:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.