标签:
问题:
获得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 }
标签:
原文地址:http://www.cnblogs.com/lettet/p/4539397.html