zoukankan      html  css  js  c++  java
  • How to easily create popup menu for DevExpress treelist z

    http://www.itjungles.com/how-to-easily-create-popup-menu-for-devexpress-treelist.html

    Adding popup menu to DevExpress treelist is an easy task. Follow these simple steps to accomplish this:

    1. Once you have the project setup and you have added the treelist to your Windows form. Go to the Toolbox and added in BarManager and Popup Menu. It is located under the section DX.9.3: Navigation & Layout.

    devexpress-treelist-popu-menu


    2. Now below for your form designer there will be two items. Click on the ResultMenu property and assign the barManager1 to the Manager property.

    devexpress-treelist-popu-menu2       >>>>>>>   devexpress-treelist-popu-menu3

    3. Now you will need to add some code to the CloseUp event for the popup menu. Double click on the CloseUp event so that it will automatically generate the event handler in the code behind file.

    devexpress-treelist-popu-menu4

    private void ResultMenu_CloseUp(object sender, EventArgs e)

            {

                if (NeedRestoreFocused)

                    tlFuncLoc.FocusedNode = SavedFocused;

            }

    4. Now you need to write some code to the treelist MouseUp event.

    On the treelist properties windows double click on the MouseUp event.

    private void tlFuncLoc_MouseUp(object sender, MouseEventArgs e)

    {

        TreeList tree = sender as TreeList;

        if (e.Button == MouseButtons.Right && ModifierKeys == Keys.None && tree.State == TreeListState.Regular)

        {

            Point pt = tree.PointToClient(MousePosition);

            TreeListHitInfo info = tree.CalcHitInfo(pt);

            if (info.HitInfoType == HitInfoType.Cell)

            {

                SavedFocused = tree.FocusedNode;

                int SavedTopIndex = tree.TopVisibleNodeIndex;

                tree.FocusedNode = info.Node;

                NeedRestoreFocused = true;

                ResultMenu.ShowPopup(MousePosition);

            }

        }

    }

    5. Add the two below variable to the top of the class.

    TreeListNode SavedFocused;

    bool NeedRestoreFocused;

    6. Now click on Customize on the Popup menu to start adding the menu item. Double click on the menu item to create the event handler for that menu item.

    devexpress-treelist-popu-menu5

    devexpress-treelist-popup-menu5

    Addtional examples:

    http://www.devexpress.com/Support/Center/KB/p/A915.aspxhttp://www.devexpress.com/Help/?document=XtraBars/CustomDocument5472.htm&levelup=true

  • 相关阅读:
    .Net Core小技巧
    调用Kubernetes API操作Kubernetes
    在CentOS 7+ 安装Kubernetes入门(单Master)
    Linux命令行基础
    使用wireshark学习TCP
    Redis原子性写入HASH结构数据并设置过期时间
    Vue使用小结
    JAVA & .NET创建对象构造函数调用顺序
    .NET 中的序列化 & 反序列化
    ASP.NET Core中使用Graylog记录日志
  • 原文地址:https://www.cnblogs.com/zeroone/p/3758325.html
Copyright © 2011-2022 走看看