编程语言
首页 > 编程语言> > How to: Access the Navigation Dock Panel (in a WinForms Application) 如何:访问导航停靠面板(在 WinForms 应用程序中)

How to: Access the Navigation Dock Panel (in a WinForms Application) 如何:访问导航停靠面板(在 WinForms 应用程序中)

作者:互联网

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

本主题介绍如何访问和自定义用于在 WinForms 应用程序中显示导航的 Dock 面板。

 

Tip 提示
A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T275956
完整的示例项目在 DevExpress 代码示例数据库中可用http://www.devexpress.com/example=T275956

.

The snippet below demonstrates 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.

在上面的代码中,baseDockOptions.ShowAutoHide按钮和BaseDockOptions.显示关闭按钮选项被更改。您也可以使用 DockPanelOptions 的其他属性。

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.
您可以在 TemplateChanged 事件处理程序中直接访问 DockPanel 对象,但在此实例中,XAF 默认值将覆盖您的设置。因此,使用 Form.Loadevent 覆盖默认值。

标签:Load,Form,DevExpress,Frame,Access,Dock,WinForms,DockPanel,TemplateChanged
来源: https://www.cnblogs.com/foreachlife/p/How-to-Access-the-Navigation-Dock-Panel-in-a-WinForm