阅读:1381回复:1
上下文菜单在TOC中使用问题
上下文菜单在TOC中使用问题<BR><BR>
<DIV>VS.NET2003,AE9.0我想在TOC中使用上下文菜单ContextMenu代码如下:<BR>private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.TOCControl.ITOCControlEvents_OnMouseDownEvent e)<BR> {<BR> //ContextMenu上下文菜单<BR> if(e.button==2)<BR> {<BR> esriTOCControlItem pItem=new esriTOCControlItem();<BR> IBasicMap pMap=new MapClass();<BR> ILayer ppLayer=null;<BR> object other=new object();<BR> object index=new object();<BR> axTOCControl1.HitTest(e.x,e.y,ref pItem,ref pMap,ref ppLayer,ref other,ref index);<BR> //MessageBox.Show(ppLayer.Name);<BR> if (pItem == esriTOCControlItem.esriTOCControlItemLayer)<BR> {<BR> <BR> contextMenu1.Show(axTOCControl1, new System.Drawing.Point(e.x, e.y));<BR> }<BR> }<BR> <BR> }<BR>可是发现只要右键都弹出上下文菜单,根本不执行if判断而且pplayer没有值,这是怎么回事?TOC没有contextmenu属性,我就在form中设置的contextmenu属性,是不是这的问题啊?谢谢</DIV> |
|
1楼#
发布于:2007-11-22 10:27
<P>有人知道吗?如果我点击层时axTOCControl1.HitTest(e.x,e.y,ref pItem,ref pMap,ref ppLayer,ref other,ref index);<BR>能够返回ppLayer值吗?我去掉MessageBox.Show(ppLayer.Name);注释后根本不弹出来box匡。谢谢!!!!请高人指点<BR></P>
|
|