AxTocControl获取选中要素

AxTocControl提供GetSelectedItem方法,此方法用于获取AxTocControl中选中要素,可以直接得到用户选择的数据,方便了我们的操作。

由于没有确定的返回值,该函数使用获取 ref 参数的方法,通过对获取到的参数进行修改,返回确定的内容。

该方法需要四个参数:

public void GetSelectedItem( 
    ref esriTOCControlItem  ItemType, 
    ref IBasicMap  BasicMap, 
    ref ILayer  Layer, 
    ref object  unk, 
    ref object  Data 
);

 ItemTypeesriTOCControlItem类型的参数

  BasicMapIBasicMap类型的参数

  LayerILayer类型的参数

UNK是未知或其他类型的参数

Data是数据类型的参数

使用方法:

获取选中的图层

        private ILayer getSeletedLyr()
        {
            IBasicMap map = null;
            ILayer layer = null;
            object other = null;
            object index = null;
            esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;

            //对于没有确定返回值 因此使用此法
            axTOCControl1.GetSelectedItem(ref item, ref map, ref layer, ref other, ref index);

            return layer;
        }

 

转载自:https://blog.csdn.net/ScapeD/article/details/84061259

You may also like...

退出移动版