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?
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.Groups.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;
Hope this helps,
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!