方法一
private void 所有图层不可见ToolStripMenuItem1_Click(object sender, EventArgs e)
{
ICompositeLayer pCompositeLayer;
for (int i = 0; i < axMapControl.LayerCount; i++)
{
if (axMapControl.get_Layer(i) is ICompositeLayer)
{
pCompositeLayer = axMapControl.get_Layer(i) as ICompositeLayer;
UnVisibleTogetlayer(pCompositeLayer);
}
}
axTOCControl1.Update();
axMapControl.Refresh();
}
private void UnVisibleTogetlayer(ICompositeLayer pCompositeLayer)
{
ICompositeLayer icolayer;
ICompositeLayer pcomLayer = pCompositeLayer;
ILayer layer = null;
for (int i = 0; i < pcomLayer.Count; i++)
{
if (pcomLayer.get_Layer(i) is ICompositeLayer)
{
icolayer = pcomLayer.get_Layer(i) as ICompositeLayer;
UnVisibleTogetlayer(icolayer);
}
layer = pcomLayer.get_Layer(i);
layer.Visible = false;
}
}
方法二
private void 所有图层不可见ToolStripMenuItem1_Click(object sender, EventArgs e)
{
ICompositeLayer pCompositeLayer;
ILayer mCompositeLayer;
for (int i = 0; i < axMapControl.LayerCount; i++)
{
if (axMapControl.get_Layer(i) is ICompositeLayer)
{
pCompositeLayer = axMapControl.get_Layer(i) as ICompositeLayer;
for (int j = 0; j < pCompositeLayer.Count; j++)
{
mCompositeLayer = pCompositeLayer.get_Layer(j);
mCompositeLayer.Visible = false;
}
}
}
axTOCControl1.Update();
axMapControl.Refresh();
}