ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

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

2019-12-26 15:01:59  阅读:354  来源: 互联网

标签:Load Form DevExpress Frame Access Dock WinForms DockPanel TemplateChanged


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 覆盖默认值。

标签: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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有