I want to enumerate through toolbars, I have an MDI application that I will have various windows in, and I want to make a menu item for "Window". I already have the Cascade, Horizontal, etc. What I want to do is build a menu of the applications that are running in the MDI container in the menu. To do this I need to manipulate the toolbar in the MdiChildActivate event I believe, essentially going through all MDI windows that are open, and creating a menu item for ones that are created or delete menu items for the ones they just closed.
Anyone have any ideas? Perhaps I am going about this the wrong way as well.
Something like:
foreach (Tool tc in this.ultraToolbarsManager1.Toolbars["Window"].Tools) { if this TC exists, delete it if it's closing, else add a menu item and a spacer at the end between the new windows and the cascade, horizontal, etc. functions. }
I have an idea of using the this.ultraToolbarsManager1.Toolbars["Window"].Tools.Count and using it in a "for (i ++)" type loop instead, but just wanted to throw this out to see what the thoughts are on the best way to accomplish this with the ultraToolbarsManager is.
Thanks ahead of time for any assistance.
Using a foreach is a good approach if you are not going to modify the collection within the loop. If you will be adding and removing tools in the loop, I would recommend using a for loop, incrementing or decrementing the loop variable approriately when the collection is modified (if you iterate backwards across the collection, like this: for(int i = manager.Toolbars[0].Tools.Count-1;i>=0;i--), you will not need to modify the loop variable when removing a tool).
I sure could! I knew there had to be an easier way, wasn't aware of this tool, seems I need to hunt the toolset that's there better next time.
But because I am a geek, and I really want to know how to do it now that I spent so much time trying to figure it out, how would one iterate through a collection of tools in a toolbar?
Actually to be correct it should be:
this.ultraToolbarsManager1.Toolbars[0].Tools["Window"].Tools.Count (although doesn't exist)
Since it's a menu tool ("windows") with button tools ("cascade, horizontal, etc.") in it and I want to manipulate those button tools, that are in the menu tool that are part of the main toolbar.