zoukankan      html  css  js  c++  java
  • DevExpress 组件动态在PopupMenu中添加项

    由于使用DevExpress 的控件,需要在PopupMenu动态添加项。根据PopupMenu的后台代码,自己写怎么添加都不显示,不知道原因何在。代码如下:

                BarButtonItem tBBI = new BarButtonItem();

                tBBI.Name = "Item1";

                tBBI.Caption = "myItem";

                this.barManager1.Items.Add(tBBI);

                this.pPop.LinksPersistInfo.Add(new LinkPersistInfo(tBBI));

     

    后来无意中,发现PopupMenu有一个AddItem方法,用了之后,可以了。很高兴。但问题接踵而至。按钮中的项,不能分组。继续找原因。知道发现这篇博客:

    http://www.cnblogs.com/supermap/archive/2006/07/01/440418.html

    很受启发,尤其是关键代码

            public PopupMenu CreateContextMenu()

            {

                PopupMenu contextMenu = new PopupMenu();

                contextMenu.Popup += new EventHandler(ContextMenuPopupHandler);

                foreach (object item in buildItems)

                {

                    if (item is BarItem)

                    {

                        bool beginGroup = false;

                        beginGroup = (bool)(item as BarItem).Tag;

                        //contextMenu.LinksPersistInfo.AddRange(new LinkPersistInfo[] { new LinkPersistInfo((item as             BarItem),         beginGroup) });

                        BarItem barItem = item as BarItem;

                        AddMenuItem(barManager, barItem);

                        //LinksPersistInfo右键菜单不出来

                        //contextMenu.LinksPersistInfo.Add(new LinkPersistInfo(barItem, beginGroup));

                        BarItemLink itemLink = contextMenu.AddItem(barItem);

                        itemLink.BeginGroup = beginGroup;

                    }

                }

                contextMenu.Manager = barManager;

                return contextMenu;

            }

    学习了!

    作者: cglnet
    本文版权归cglNet和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    linux的mount(挂载)命令详解
    数据库为什么要用B+树结构--MySQL索引结构的实现
    数据结构 B-树和B+树的应用:数据搜索和数据库索引
    Mysql索引的类型和优缺点
    InnoDB事务隔离级别
    ResultSet相关ResultSetMetaData详细
    header中Content-Disposition的作用
    Cannot change version of project facet Dynamic Web Module to 3.0 异常问题处理
    transient关键字
    JSP页面嵌套乱码解决
  • 原文地址:https://www.cnblogs.com/cglNet/p/2658207.html
Copyright © 2011-2022 走看看