How to: Access the Navigation Dock Panel (in a WinForms Application) How to: navigation dock access panel (in WinForms application)

This topic describes how to access and customize the Dock Panel used to display Navigation in WinForms applications.

This topic describes how to access and customize the display for navigation in WinForms applications Dock panel.

 

Tip Tip
A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T275956
The complete sample project is available in the DevExpress Code sample database http://www.devexpress.com/example=T275956

.

  • Inherit WindowController in the WinForms module project.
  • In the constructor, set the WindowController.TargetWindowType property to Main.
  • Override the OnActivated method and subscribe to the Frame.TemplateChanged event.
  • In the TemplateChanged event handler, cast Frame.Template to Form and subscribe to the Form.Load event.
  • In the Load event handler, cast the template to the INavigationPanelHolder type and access the DockPanel object using the DockPanelNavigation property.
  • Inheritance in WinForms window controller module project.
  • In the constructor, the WindowController.TargetWindowType property to Main.
  • On activated covering methods and subscribe to Frame. Template change events.
  • In the event handler template changes, the Frame. Templates into a form and subscribe Form.Load event.
  • In the Load event handler, I cast to the template navigation panel owner type, property access and use the navigation DockPanel DockPanel object.

The snippet below demonstrates these steps.

The following code segment illustrates these steps.

using System.Windows.Forms;
using DevExpress.ExpressApp;
// ...
public class HideNavigationPanelButtonsController : WindowController {
    public HideNavigationPanelButtonsController() {
        this.TargetWindowType = WindowType.Main;
    }
    protected override void OnActivated() {
        base.OnActivated();
        Frame.TemplateChanged += Frame_TemplateChanged;
    }
    private void Frame_TemplateChanged(object sender, EventArgs e) {
        Form form = (Form)Frame.Template;
        form.Load += Form_Load;
    }
    private void Form_Load(object sender, EventArgs e) {
        if(Frame.Template is DevExpress.ExpressApp.Win.Templates.INavigationPanelHolder) {
            DevExpress.XtraBars.Docking.DockPanel navigationPanel = 
                 ((DevExpress.ExpressApp.Win.Templates.INavigationPanelHolder)Frame.Template).DockPanelNavigation;
            navigationPanel.Options.ShowAutoHideButton = false;
            navigationPanel.Options.ShowCloseButton = false;
        }
    }
    protected override void OnDeactivated() {
        Frame.TemplateChanged -= Frame_TemplateChanged;
        base.OnDeactivated();
    }
}

 

In the code above, the BaseDockOptions.ShowAutoHideButton and BaseDockOptions.ShowCloseButton options are changed. You can use other properties of the DockPanelOptions as well.

In the above code, baseDockOptions.ShowAutoHide button and BaseDockOptions. Display Off button option is changed. You can also use other attributes of DockPanelOptions.

Important Important
You can access the DockPanel object directly in the TemplateChanged event handler, but your settings will be overriden by XAF defaults in this instance. So, use the Form.Loadevent to override defaults.
You can directly access the DockPanel object TemplateChanged event handler, but in this instance, XAF default values ​​will override your settings. Therefore, Form.Loadevent override the default values.

Guess you like

Origin www.cnblogs.com/foreachlife/p/How-to-Access-the-Navigation-Dock-Panel-in-a-WinForms-Application.html
Recommended