How to: How to Access the Office Navigation Bar: Visit the Office navigation bar

This topic demonstrates how to access the Office Navigation Bar used to show the navigation root groups when the OutlookStyleMainRibbonForm Template is used in a WinForms application.

Office Access is used to display the navigation bar navigation root group This topic demonstrates how to use a form template OutlookStyleMainRibbon in WinForms applications.

 

Tip Tip
A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T392480
Complete sample project can be found in the code sample database DevExpress, http://www.devexpress.com/example=T392480

 

Perform the following steps to access the OfficeNavigationBar object and customize its settings.

Create a new WindowController in your WinForms module.

2.The OfficeNavigationBar control is located on the OutlookStyleMainRibbonFormTemplate (see IModelRootGroupsStyle.RootGroupsStyle). To access this Template after it has been created or changed, override the Controller's OnActivated method and subscribe to the Frame.TemplateChanged event of the main Window.

3.In the TemplateChanged event handler, cast the Frame.Template property to the Form type and handle the Form.Load event.

4.In the Form.Load event handler, cast the sender to the IOfficeNavigationBarHolder type.

5.To access the OfficeNavigationBar object, use the IOfficeNavigationBarHolder.OfficeNavigationBar property. For instance, you can set the OfficeNavigationBar.MaxItemCount property to 4 to change the maximum number of items simultaneously displayed within the OfficeNavigationBar control.

6.Unsubscribe from the TemplateChanged event in the overridden OnDeactivated method when the Controller is deactivated.

 

Follow these steps to access the Office navigation bar objects and customize its settings.

1. Create a new window in WinForms controller module.

2.Office navigation controls located OutlookStyleMainRibbon form template (See ImodelrootGroupsStyle.rootGroups style). To access this template after you create or change this template, please Frame.templateChanged event rewrite OnActivated method controllers and subscribe to the main window.

3.In the event handler template changes will Frame.Template properties into the form and type of treatment Form.Load event.

4.In Form.Load event handler to convert the sender to IOffice navigation bar type.

When 5.To Office navigation bar to access an object, use IOffice navigation bar. For example, you can Office navigation bar .MaxItemCount property is set to 4 to change the maximum number of items Office navigation bar controls simultaneously displayed.

6. When the controller is disabled, unsubscribe rewritten On deactivation template method change events.

using DevExpress.ExpressApp.Win.Templates;
using DevExpress.XtraBars.Ribbon;
//...
public class OfficeNavigationBarCustomizationController : WindowController {
    private void Frame_TemplateChanged(object sender, EventArgs e) {
        Form form = Frame.Template as Form;
        if(form != null) {
            form.Load += Form_Load;
        }
    }
    private void Form_Load(object sender, EventArgs e) {
        IOfficeNavigationBarHolder officeNavigationBarHolder = sender as IOfficeNavigationBarHolder;
        if(officeNavigationBarHolder != null) {
            officeNavigationBarHolder.OfficeNavigationBar.MaxItemCount = 4;
        }
    }
    protected override void OnActivated() {
        base.OnActivated();
        Frame.TemplateChanged += Frame_TemplateChanged;
    }
    protected override void OnDeactivated() {
        Frame.TemplateChanged -= Frame_TemplateChanged;
        base.OnDeactivated();
    }

    public OfficeNavigationBarCustomizationController() {
        TargetWindowType = WindowType.Main;
    }
}

 

Run the application to ensure that the maximum number of visible OfficeNavigationBar items is 4.

Run the application to ensure visibility Office navigation bar item maximum number of 4.

Guess you like

Origin www.cnblogs.com/foreachlife/p/How-to-Access-the-Office-Navigation-Bar.html