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?

  • 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
    Commented Oct 17, 2012 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
    Commented Oct 17, 2012 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
    Commented Oct 17, 2012 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
    Commented Oct 17, 2012 at 19:50

3 Answers 3


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.

  • +1 I removed my answer since this is the easiest way to accomplish the task.
    – Radar
    Commented Oct 17, 2012 at 19:09
  • How will this fare across multiple layers/classes where the OID may be duplicated?
    – AHigh
    Commented Oct 17, 2012 at 19:19
  • 1
    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
    Commented Oct 17, 2012 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
    Commented Oct 17, 2012 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
    Commented Oct 17, 2012 at 19:32

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 http://img21.imageshack.us/img21/888/25305cdbf5b24533beb4420.png

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.

  • 1
    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
    Commented Oct 17, 2012 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
    Commented Oct 17, 2012 at 20:06

use this code to unselect selected features.

  Dim ifs As IFeatureSelection = layer ' layer as IFeatureLayer
  Dim arr() As Integer = {25,26}
  ifs.SelectionSet.RemoveList(2, arr(0)) '  arr(0) is pointer to arr


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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