zoukankan      html  css  js  c++  java
  • 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

    .

    • 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.
    • 在 WinForms 模块项目中继承窗口控制器。
    • 在构造函数中,将 WindowController.TargetWindowType 属性设置为 Main。
    • 覆盖 On 已激活的方法并订阅 Frame.模板更改事件。
    • 在模板更改事件处理程序中,将 Frame.模板转换为窗体并订阅 Form.Load 事件。
    • 在 Load 事件处理程序中,将模板强制转换为 I 导航面板所有者类型,并使用 DockPanel 导航属性访问 DockPanel 对象。

    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 覆盖默认值。
  • 相关阅读:
    “XXXXX” is damaged and can’t be opened. You should move it to the Trash 解决方案
    深入浅出 eBPF 安全项目 Tracee
    Unity3d开发的知名大型游戏案例
    Unity 3D 拥有强大的编辑界面
    Unity 3D物理引擎详解
    Unity 3D图形用户界面及常用控件
    Unity 3D的视图与相应的基础操作方法
    Unity Technologies 公司开发的三维游戏制作引擎——Unity 3D
    重学计算机
    windows cmd用户操作,添加,设备管理员组,允许修改密码
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Access-the-Navigation-Dock-Panel-in-a-WinForms-Application.html
Copyright © 2011-2022 走看看