Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using the esriControls.ControlsSelectTool I select a text element that I have previously placed on the map. In code, how can I find this element on the map? I know I can iterate using the IGraphicsContainer but how can I tell that the element is the selected element?

share|improve this question

Should have known another interface would be waiting (given that 'view' is an IActiveView):

IElement selectedElement = null;
IGraphicsContainerSelect graphicsContainerSelect = 
    view.FocusMap as IGraphicsContainerSelect;
if ( graphicsContainerSelect == null ) return selectedElement;
if ( graphicsContainerSelect.ElementSelectionCount == 0 ) return selectedElement;
IEnumElement enumElement = graphicsContainerSelect.SelectedElements;
selectedElement = enumElement.Next();
while ( selectedElement != null ) {
    // whatever
    selectedElement = enumElement.Next();
share|improve this answer

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.