Articles and Tutorials

Removing ToolBars from the Context Menu

Author: Mike Palmatier
Platform: Visual Basic 6.0

When you right-click on any area of the CommandBars a Context Menu is displayed with the name of all the ToolBars that have been added. This menu allows you to hide or display a toolbar. By default, all ToolBars are added to this menu. To remove a ToolBar from the menu, set the CommandBars.ContextMenuPresent property to False.

To completely remove the Context Menu, you need to remove the entry for ToolBars.

Toolbar Context Menu

The code below will remove the first toolbar from the ContextMenu.

CommandBars(2).ContextMenuPresent = False

The code below will remove all toolbars from the ContextMenu, which will in effect "disable" the menu. This is useful when you want to display your own context menu instead of the standard one.

Private Sub CommandBars_ToolBarContextMenu(ByVal ToolBar As XtremeCommandBars.ICommandBar, ByVal ContextMenu As XtremeCommandBars.ICommandBar)
    ContextMenu.Controls.DeleteAll
End Sub

Articles and Tutorials