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?
Wow, thank you for posting this! I know it's 9 years old but I have been fighting with how to do this for a few days. I was not removing the tool from the toolbar manager's root tool collection. Thank you!
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~