Search code examples
c#arcgisarcmap

How To make a Layer Only select able In ArcMap through API


In ArcMap any Layer can be made only select able through Right Click->Selection->Make This the Only Select able Layer. I want to do it programmatically through ArcMap API. I am a newbie in arcgis.


Solution

  • I have solved this in this way: very simple solutin, i am a newbie in arcgis

    private void MakeOnlySelectableLayer(IFeatureLayer stationFeatureLayer)
    {
        var Focusmap = ArcMap.Document.FocusMap;
    
        for (int i = 0; i < Focusmap.LayerCount; i++)
        {
            if (Focusmap.get_Layer(i) is IFeatureLayer)
            {
                IFeatureLayer layer = (IFeatureLayer)Focusmap.get_Layer(i);
                if (stationFeatureLayer != null && !stationFeatureLayer.Equals(layer))
                {
                  layer.Selectable = false;
                }
    
    
            }
         }
     }