zoukankan      html  css  js  c++  java
  • 获得TOCControl中的选中图层

    问题: 

    获得TOCControl中的选中图层,并对其判断如果是组图层则进行添加操作。

    解决方法:

    使用TOCControl.GetSelectedItem()方法。

    示例代码:

     1             esriTOCControlItem tocChoosedItem = esriTOCControlItem.esriTOCControlItemNone;
     2             IBasicMap pBasicMap = null;
     3             ILayer tocChoosedLyr = null;
     4             object pOther = new object();
     5             object pIndex = new object();
     6             m_Application.TOCControl.GetSelectedItem(ref tocChoosedItem, ref pBasicMap, ref tocChoosedLyr, ref pOther, ref  pIndex); 
     7            
     8             if (tocChoosedLyr is IGroupLayer)
     9             {
    10                 ICompositeLayer compositeLyr = tocChoosedLyr as ICompositeLayer;
    11                 int childLyrCount = compositeLyr.Count;
    12                 for (int j = 0; j < childLyrCount; j++)
    13                 {
    14                     ILayer childLyr = compositeLyr.get_Layer(j);
    15                     object[] objs = new object[] { childLyr.Name, true };
    16                     dataGridView1.Rows.Add(objs);
    17                 }
    18             }
  • 相关阅读:
    生命周期-BeanPostProcessor-后置处理器
    生命周期-@PostConstruct&@PreDestroy
    生命周期-InitializingBean和DisposableBean
    异常安全
    inline函数
    bool类型
    函数重载与默认参数
    C++强制转换
    引用
    new/delete表达式
  • 原文地址:https://www.cnblogs.com/lettet/p/4539397.html
Copyright © 2011-2022 走看看