Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.