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
1176
visit each ribon toolbar menu and submenu
posted

hi i have an app that ask for login and after the usr log on the app will visit each submenu from each menu and enable or disable the submenu acoording to it access, right now i can get a count on menus and a count on submenus to visit each of them on vbnet 2008, can i aslo be able of doing the same using the ribom menu ?

 

Thanks.

  • 5389
    Verified Answer
    posted

    PAVCBC,

    You can do this by looping through the UltraToolbarsManager Ribbon's Tabs collection, and then through each RibbonTab's RibbonGroups collection.  You then need to loop through each RibbonGroup's Tools collection.  If any of those tools are PopupMenuTools (that contain other tools), you will need to loop through their Tools collection as well.  The best way to do that last part is via aa recursive loop.  The code for the entire thing might look something like:

    foreach (RibbonTab tab in this.ultraToolbarsManager1.Ribbon.Tabs)
                {
                    foreach (RibbonGroup group in tab.Groups)
                    {
                        foreach (ToolBase tool in group.Tools)  //this gives us all the tools directly in a RibbonGroup
                        {
                            if (tool.GetType() == typeof(PopupMenuTool))
                            {
                                PopupMenuTool pTool = tool as PopupMenuTool;
                                LoopThroughTools(pTool);
                            }
                        }
                    }
                }

     private void LoopThroughTools(PopupMenuTool parent)
            {
                foreach (ToolBase child in parent.Tools)
                {
                    if (child is PopupMenuTool)
                    {
                        PopupMenuTool pTool = child as PopupMenuTool;
                        LoopThroughTools(pTool);
                    }
                }
            }

     

    Hope this helps,

    ~Kim~