• 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));
                    }
                }
            }


  • 相关阅读:
    p1012拼数题解
    LeetCode OJ :Unique Binary Search Trees II(唯一二叉搜索树)
    UVA 11827 Maximum GCD
    LightOJ1336 Sigma Function(约数和为偶数的个数)
    LightOJ 1197 Help Hanzo(区间素数筛选)
    LightOJ 1236
    BZOJ3339 Rmq Problem
    COJ983 WZJ的数据结构(负十七)
    LCA的五种解法
    hdu4223(dp)
  • 原文地址:https://www.cnblogs.com/dengshiwei/p/4258771.html
Copyright © 2020-2023  润新知