zoukankan      html  css  js  c++  java
  • TreeList控件右键菜单功能的实现

    <p>TreeList控件实现右键菜单功能,其实跟TocControl控件实现原理是一样的,TocControl也是利用一个ContextMenu控件,利用HitT方法,TreeList利用其ContextMenuStrip属性就可以。</p><p>TocControl实现右键功能:</p>
     private void MenuList_MouseDown(object sender, MouseEventArgs e)
            {
                //绑定右键菜单
                if (e.Button == MouseButtons.Right)
                {
                    MenuList.ContextMenu = null;
                    TreeListHitInfo hInfo = MenuList.CalcHitInfo(new Point(e.X, e.Y));
                    TreeListNode node = hInfo.Node;
                    MenuList.FocusedNode = node;
                    if (node != null)
                    {
                        MenuList.ContextMenuStrip = contextMenu;
                    }
                }
            }

    TreeList实现右键功能:

      private void axTOCControl_OnMouseDown_1(object sender, ITOCControlEvents_OnMouseDownEvent e)
            {
    
                if (e.button == 2)
                {
                    esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
                    IBasicMap m_BasicMap = null;
                    ILayer m_Layer = null;
                    object other = null;
                    object index = null;
                    axTOCControl.HitTest(e.x, e.y, ref item, ref m_BasicMap, ref m_Layer, ref other, ref index);
                    g_Layer = m_Layer;
                    if (item == esriTOCControlItem.esriTOCControlItemLayer)
                    {
                        cMStoc.Show(axTOCControl, new System.Drawing.Point(e.x, e.y));
                    }
                }
            }


  • 相关阅读:
    WPF自定义控件
    NPOI设置Excel单元格字体、边框、对齐、背景色
    关于StreamReader.ReadToEnd方法
    ASP.NET Core Web多语言项目
    docker与虚拟机的区别
    C# Task.Run 和 Task.Factory.StartNew 区别
    MVC的SignalR例子
    深圳游玩攻略
    一个域名下多个Vue项目
    Linq的执行效率及优化
  • 原文地址:https://www.cnblogs.com/dengshiwei/p/4258771.html
Copyright © 2011-2022 走看看