Get currently selected features

5779
1
Jump to solution
07-26-2012 06:32 AM
KevinYanuk
Occasional Contributor
Hello -

I am new to C# ArcObjects, and I am looking to get a handle on how to retrieve selected features within a map document.


Basically, the user will select some features (either query or manual rectangle-select).  When they click a button on the addin, it will perform some functions.


I basically need a kickstart of how to retrieve the features they have just selected.


Thank you!
0 Kudos
1 Solution

Accepted Solutions
EricWeber
New Contributor III
Have you already gotten a reference to the feature layer from the table of contents? If so, cast the feature layer to the IFeatureSelection interface, and use that interface's SelectionSet property:

ISelectionSet selectedFeatures = ((IFeatureSelection)featureLayer).SelectionSet


You can then use a cursor over the selection set to access the individual features in the selection.

View solution in original post

0 Kudos
1 Reply
EricWeber
New Contributor III
Have you already gotten a reference to the feature layer from the table of contents? If so, cast the feature layer to the IFeatureSelection interface, and use that interface's SelectionSet property:

ISelectionSet selectedFeatures = ((IFeatureSelection)featureLayer).SelectionSet


You can then use a cursor over the selection set to access the individual features in the selection.
0 Kudos