zoukankan      html  css  js  c++  java
  • How to: Access the Bar Manager 如何:访问Bar管理器

    WinForms applications use the Bar Manager to show an application's menu when the ribbon interface is disabled (see IModelOptionsWin.FormStyle), and to display a nested Frame's toolbar. This topic describes how to access the Bar Manager. Refer to the How to: Customize Action Controls topic to learn how to customize baritems.

    当功能区界面被禁用时,WinForms 应用程序使用条形管理器来显示应用程序的菜单(请参阅 IModelOptionsWin.FormStyle),并显示嵌套框架的工具栏。本主题介绍如何访问条形管理器。请参阅"如何:自定义操作控制"主题,了解如何自定义栏项。

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

    .

    Follow the steps below to access the BarManager object and customize its settings:

    1. Create a new Controller in the WinForms module's Controllers folder. This Controller customizes Bar Managers in all Frames, including nested Frames (see NestedFrame).
    2. Override the Controller's OnActivated method and subscribe to the Frame.TemplateChanged event.
    3. In the TemplateChanged event handler, ensure that the Frame.Template's type is IBarManagerHolder. Cast the Template to the IBarManagerHolder type and use the IBarManagerHolder.BarManager property to access the BarManager object. For instance, you can set the BarManager.AllowCustomization property to false to prohibit end-users from customizing a bar.
    4. Override the Controller's OnDeactivated method and unsubscribe from the TemplateChanged event when the Controller is deactivated.

    按照以下步骤访问 BarManager 对象并自定义其设置:

    1. 在 WinForms 模块的控制器文件夹中创建新的控制器。此控制器自定义所有帧中的条形管理器,包括嵌套帧(请参阅嵌套框架)。

    2. 覆盖控制器的 On 已激活方法并订阅 Frame.模板更改事件。

    3. 在模板更改事件处理程序中,确保 Frame.Template 的类型为 IBarManagerHolder。将模板转换为 IBarManagerHolder 类型,并使用 IBarManager.BarManager 属性访问 BarManager 对象。例如,您可以将 BarManager.AllowCustomization 属性设置为 false,以禁止最终用户自定义条形。

    4. 覆盖控制器的 OnDeon 已激活方法,并在停用控制器时取消订阅模板更改事件。

    using System;
    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Win.Controls;
    using DevExpress.XtraBars;
    // ...
    public class BarManagerCustomizationWindowController : Controller {
        protected override void OnActivated() {
            base.OnActivated();
            Frame.TemplateChanged += Frame_TemplateChanged;
        }
        private void Frame_TemplateChanged(object sender, EventArgs e) {
            if (Frame.Template is IBarManagerHolder) {
                BarManager manager = ((IBarManagerHolder)Frame.Template).BarManager;
                manager.AllowCustomization = false;
            }
        }
        protected override void OnDeactivated() {
            Frame.TemplateChanged -= Frame_TemplateChanged;
            base.OnDeactivated();
        }
    }

    Run the application to ensure that bar customization is not allowed.

    运行应用程序以确保不允许进行栏自定义。

    BarManager_AllowCustomization

  • 相关阅读:
    1.1 Recruitment 1.1.4 Sample Test(II)
    1.1 Recruitment 1.1.4 Sample Test(I)
    微信登录接口
    谷歌浏览器保留页面跳转前的请求
    积分墙项目接口文档
    @SneakyThrows
    security中使用单元测试
    Prometheus监控系统
    大数据-shell-脚本入门-开头格式、运行方式、多命令处理
    大数据-shell-概述
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Access-the-Bar-Manager.html
Copyright © 2011-2022 走看看