Select to view content in your preferred language

IFeatureSelection :: Clear does not clear graphics selection

1082
3
Jump to solution
06-04-2012 01:06 PM
SachaTousignant
Regular Contributor
Hello everyone,

I'm having trouble with the following :
I have a selection on features and store it into an IFeatureSelection. Then I clear the selection with the method Clear().
The featureselection is indeed empty, but on the map, I still see that the features are selected, but they are not really in reality.

// My selection of features IFeatureSelection plantSelection = infosXML.LayerPlant as IFeatureSelection; // Load of code ... // Clear the selection plantSelection.Clear();  // Refresh the screen ArcMap.Document.ActiveView.Refresh();


Any help would be REALLY appreciated! Ty all
0 Kudos
1 Solution

Accepted Solutions
SachaTousignant
Regular Contributor
You're calling Refresh on the document's active view.  If the document is in Layout view then this will refresh the layout and not the map inside of the map frame.  If the document is in Data view then this will refresh the map in the table of contents that is currently active.  If you are calling this code while in Data view and the map that contains the layer is active then this should work.  Otherwise, you will need to get the appropriate active view reference before calling Refresh.


Ty Neil for your reply, I found out how to fix my problem, here's the code in case someone else needs it

IActiveView activeView = ArcMap.Document.FocusMap as IActiveView; activeView.Refresh();

View solution in original post

0 Kudos
3 Replies
NeilClemmons
Honored Contributor
You're calling Refresh on the document's active view.  If the document is in Layout view then this will refresh the layout and not the map inside of the map frame.  If the document is in Data view then this will refresh the map in the table of contents that is currently active.  If you are calling this code while in Data view and the map that contains the layer is active then this should work.  Otherwise, you will need to get the appropriate active view reference before calling Refresh.
0 Kudos
KenBuja
MVP Esteemed Contributor
This might be once of the cases where you have to refresh twice.
0 Kudos
SachaTousignant
Regular Contributor
You're calling Refresh on the document's active view.  If the document is in Layout view then this will refresh the layout and not the map inside of the map frame.  If the document is in Data view then this will refresh the map in the table of contents that is currently active.  If you are calling this code while in Data view and the map that contains the layer is active then this should work.  Otherwise, you will need to get the appropriate active view reference before calling Refresh.


Ty Neil for your reply, I found out how to fix my problem, here's the code in case someone else needs it

IActiveView activeView = ArcMap.Document.FocusMap as IActiveView; activeView.Refresh();
0 Kudos