求删除选中项的代码 今天用ArcEngine 中的组件堆成一个小窗体,想添加一些右键功能。如何实现删除鼠标左键已经选中的选项。请高手们给点代码例子! 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以用ContextMenu,添加你想要的菜单,实现功能,然后关联datagridview和ContextMenu即可 contextmenu控件已经做出来了,不过做的是在鼠标位置处显示右键菜单,怎么做到给选中项(是我在小程序中打开的一个文件,随即的)添加固定的右键功能? 请大侠们给点帮助 右击toccontrol 产生removelayerremovelayer.cs public sealed class RemoveLayer : BaseCommand { private IMapControl3 m_mapControl; public RemoveLayer() { base.m_caption = " Remove Layer"; } public override void OnClick() { ILayer pLayer = (ILayer)m_mapControl.CustomProperty; m_mapControl.Map.DeleteLayer(pLayer); } public override void OnCreate(object hook) { m_mapControl = (IMapControl3)hook; } }load事件中:m_menuLayer = new ToolbarMenuClass(); m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);toccontrol_onmousedown事件中: //右击删除图层 esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone; IBasicMap map = null; ILayer layer = null; object other = null; object index = null; m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //Ensure the item gets selected if (item == esriTOCControlItem.esriTOCControlItemMap) m_tocControl.SelectItem(map, null); //axTOCControl1.SelectItem(map, null); else m_tocControl.SelectItem(layer, null); //axTOCControl1.SelectItem(layer, null); //Set the layer into the CustomProperty (this is used by the custom layer commands) m_mapControl.CustomProperty = layer; //axTOCControl1.CustomProperty = layer; //Popup the correct context menu if (item == esriTOCControlItem.esriTOCControlItemMap) m_menuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd); if (item == esriTOCControlItem.esriTOCControlItemLayer) m_menuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd); C#程序因为最大化,控件显示错位,怎么解决?新人求解答。 ASP.net 将页面 导导入word的问题 C# 引用类型 求高手转换代码c++转换成c# 谁知道把网站链接变成字啊 关于TREEVIEW的图标问题,谢谢大家帮忙!!! 我想獲取類屬性的名字應該怎麼辦? 一个想法,对付现在要求你骗取别人点击获得积分疯狂宣传的网站的办法。 C# C/S客户端快捷键问题 我想用ASP.net做个bombman 在winform中用httpwebrequest表单post登录失败。 讨论类的私有变量是否也以属性的方式使用呢?
removelayer.cs
public sealed class RemoveLayer : BaseCommand
{
private IMapControl3 m_mapControl; public RemoveLayer()
{
base.m_caption = " Remove Layer";
} public override void OnClick()
{
ILayer pLayer = (ILayer)m_mapControl.CustomProperty;
m_mapControl.Map.DeleteLayer(pLayer);
} public override void OnCreate(object hook)
{
m_mapControl = (IMapControl3)hook;
}
}
load事件中:
m_menuLayer = new ToolbarMenuClass();
m_menuLayer.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
toccontrol_onmousedown事件中:
//右击删除图层
esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
IBasicMap map = null; ILayer layer = null;
object other = null; object index = null;
m_tocControl.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
//Ensure the item gets selected
if (item == esriTOCControlItem.esriTOCControlItemMap)
m_tocControl.SelectItem(map, null);
//axTOCControl1.SelectItem(map, null);
else
m_tocControl.SelectItem(layer, null);
//axTOCControl1.SelectItem(layer, null); //Set the layer into the CustomProperty (this is used by the custom layer commands)
m_mapControl.CustomProperty = layer;
//axTOCControl1.CustomProperty = layer; //Popup the correct context menu
if (item == esriTOCControlItem.esriTOCControlItemMap) m_menuMap.PopupMenu(e.x, e.y, axTOCControl1.hWnd);
if (item == esriTOCControlItem.esriTOCControlItemLayer) m_menuLayer.PopupMenu(e.x, e.y, axTOCControl1.hWnd);