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

转载于:https://www.cnblogs.com/zeroone/p/3758325.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值