Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1290
Remove tools, including the keys
posted

Hi,

I have programmatically added a few Button Tools under a PopupMenuTool in my ribbon control. How can I loop the PopupMenuTool to remove all the ButtonTools that I have added?

Parents
  • 5389
    Suggested Answer
    posted

    cidolfus,

    You want to loop through the PopupMenuTools collection and remove each tool, and then remove that tool from the UltraToolbarsManager's root Tools collection as well.  The code, in C#, would look something like:

    PopupMenuTool popup = (PopupMenuTool)this.ultraToolbarsManager1.Ribbon.Tabs[0].Groups[0].Tools["PopupMenuTool3"];
    for (int i = popup.Tools.Count - 1; i >= 0; i--)
    {
        ToolBase tool = popup.Tools[i];
        if (tool.GetType() == typeof(ButtonTool))
        {
            string key = tool.Key;
            popup.Tools.Remove(tool);
            this.ultraToolbarsManager1.Tools.Remove(this.ultraToolbarsManager1.Tools[key]);
        }
    }

    Hope this helps,

    ~Kim~

Reply Children
No Data