码迷,mamicode.com
首页 > 其他好文 > 详细

获得TOCControl中的选中图层

时间:2015-05-29 21:39:20      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

问题: 

获得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             }

 

获得TOCControl中的选中图层

标签:

原文地址:http://www.cnblogs.com/lettet/p/4539397.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!