How to: Enumerate, Show, Hide, and Position Modules in the Navigation Pane
Outlook Developer Reference |
The NavigationModules property of the NavigationPane object in Microsoft Office Outlook 2007 provides access to the navigation modules contained by the Navigation Pane. You can use the Item method to enumerate the NavigationModule objects contained by the collection, as the Item method is both the default property and the indexer property for the NavigationModules collection. The CurrentModule property determines which NavigationModule object is currently selected in the Navigation Pane.
Also, each NavigationModule object provides several properties that can be used to show, hide, or change the display position of modules in the Navigation Pane:
- The Visible property determines whether a NavigationModule object can be displayed in the Navigation Pane.
- The Position property determines the ordinal position of a NavigationModule object when displayed in the Navigation Pane.
The DisplayedModuleCount property of the NavigationPane object determines the number of visible NavigationModule objects that can be displayed by the Navigation Pane. If the Visible property of a NavigationModule object is set to False, or if the Position property of the NavigationModule object is set such that the module doesn't fall within the number of visible NavigationModule objects that can be displayed in the Navigation Pane, the module isn't displayed.
The following sample consists of three event handlers:
- An event handler for the FolderContextMenuDisplay event of the Application object, which adds two new menu items named Move module to top and Show all modules to the bottom of the folder context menu, as a separate group.
- An event handler for the Click event of the Move module to top menu item, which sets the currently selected module as the topmost displayed module in the Navigation Pane.
- An event handler for the Click event of the Show all modules menu item, which makes all of the modules contained in the Navigation Pane visible and ensures that all modules are displayed by the Navigation Pane.
This sample performs the following actions:
- The FolderContextMenuDisplay event handler creates a new CommandBarButton object,
objMoveButton
, in the folder context menu. It then sets the BeginGroup property to True, to start a new group at the bottom of the context menu, and sets the Caption property to Move module to top. - It then creates a new CommandBarButton object,
objShowButton
, in the folder context menu and sets the Caption property to Show all modules. - If the Move module to top menu item is selected in the folder context menu, the Click event handler for
objMoveButton
uses the NavigationPane property of the Explorer object to retrieve a NavigationPane object. - It then uses the CurrentModule property of the NavigationPane object to retrieve the currently selected NavigationModule object and sets the Position property of that NavigationModule object to 1, making it the topmost displayed module in the Navigation Pane.
- If the Show all modules menu item is selected in the folder context menu, the Click event handler for the CommandBarButton object
objShowButton
uses the NavigationPane property of the Explorer object to retrieve a NavigationPane object. - It then enumerates the Modules collection of the NavigationPane object, setting the Visible property of each NavigationModule object contained in the collection to True.
- It finally sets the DisplayedModuleCount property of the NavigationPane object to the value of the Count property of the NavigationModules collection for the NavigationPane object, ensuring that every navigation module contained in the Navigation Pane is visible to the user.
|