首页 / ACCESS / How to: Access the Navigation Dock Panel (in a WinForms Application) 如何:访问导航停靠面板(在 WinForms 应用程序中)
How to: Access the Navigation Dock Panel (in a WinForms Application) 如何:访问导航停靠面板(在 WinForms 应用程序中)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了How to: Access the Navigation Dock Panel (in a WinForms Application) 如何:访问导航停靠面板(在 WinForms 应用程序中),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2919字,纯文字阅读大概需要5分钟。
内容图文
![How to: Access the Navigation Dock Panel (in a WinForms Application) 如何:访问导航停靠面板(在 WinForms 应用程序中)](/upload/InfoBanner/zyjiaocheng/649/b0e07dab435340afa44374a9be7586d4.jpg)
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 覆盖默认值。
内容总结
以上是互联网集市为您收集整理的How to: Access the Navigation Dock Panel (in a WinForms Application) 如何:访问导航停靠面板(在 WinForms 应用程序中)全部内容,希望文章能够帮你解决How to: Access the Navigation Dock Panel (in a WinForms Application) 如何:访问导航停靠面板(在 WinForms 应用程序中)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。