阅读:1612回复:3
求助使用deletelayer函数
<P>private void deletealllayer_Click(object sender, System.EventArgs e)//删除所有文档-----有错误<BR> {<BR> <BR> <BR> <BR> int Count=axMapControl1.LayerCount;//计算图层数目<BR> int i;<BR> for(i=0;i<=Count-1;i++)<BR> {<BR> axMapControl1.DeleteLayer(i);<BR> <BR> }<BR> <BR> <BR> }</P>
<P>为啥老出现The specified index is out of range错误。</P> |
|
1楼#
发布于:2007-09-21 15:00
<P>为什么不用axMapControl1.<a href="mk:@MSITStore:D:\Program%20Files\ArcGIS\DeveloperKit\Help\COM\VB\esriControls.chm::/ctrl_IMapControl2_ClearLayers.htm" target="_blank" ><STRONG>ClearLayers</STRONG></A>,一下清楚所有图层。。。。</P>
<P>如果你非常想用axMapControl1.DeleteLayer(i);<BR>我认为你的代码需要该一下,count你图层的数目,但当你删除一个图层后,count就会减小,所以用用for循环删除肯定有错误。</P> <P>while(axMapControl1.LayerCount>0)</P> <P> axMapControl1.DeleteLayer(0);</P> |
|
2楼#
发布于:2007-09-22 15:00
谢谢,结贴!
|
|
3楼#
发布于:2007-09-22 15:30
<a href="http://www.gisempire.com/bbs/dispbbs.asp?BoardID=62;ID=63011;replyID=65927;skin=1" target="_blank" ><FONT color=#000000 size=+0>谢谢</FONT></A>
|
|