DrColgate

IContentsView SelectedItem Enumerator

Discussion created by DrColgate on Nov 8, 2011
Latest reply on Dec 4, 2011 by DrColgate
I'm trying to get a list of Layers selected in the Table of Contents.  That is they are highlighted whether they are checked on or off in the tick box.

When I get the selected item and a single layer is selected in the ToC  the returned object is an ILayer.  However if more than one layer is selected it is not an IEnumLayer which I thought was logical and it is not a System.Array which seemed to be alluded to but not stated specifically.

It is stated that the return value could be an enum but I don't know which Enum type to cast to.

In the code below if multiple layers are selected in the ToC what is the type of object x?


IMxDocument mxDocument = (IMxDocument)ChangeMultipleSymbology_AddIn.ArcMap.Document;
IActiveView activeView = (IActiveView)mxDocument.ActiveView;
IContentsView contentsView = (IContentsView)mxDocument.CurrentContentsView;
        
System.Object x = contentsView.SelectedItem;



If there is a better way to get a list of values that are selected in the ToC I am open to suggestions.

Outcomes