zoukankan      html  css  js  c++  java
  • How to: Access the Ribbon Control 如何:访问功能区控件

    This topic demonstrates how to access the Ribbon control used to show the WinForms application menu when the IModelOptionsWin.FormStyle property is set to Ribbon (when the ribbon interface is enabled). Refer to the How to: Customize Action Controls topic to learn how to customize bar items.

    本主题演示如何在 IModelOptionsWin.FormStyle 属性设置为功能区(启用功能区界面时)访问用于显示 WinForms 应用程序菜单的功能区控件。请参阅"如何:自定义操作控制"主题,了解如何自定义栏项。

    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 RibbonControl object and customize its settings:

    1. Create a new WindowController in the WinForms module's Controllers folder.
    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 RibbonForm. Use the RibbonForm.Ribbon property to access the RibbonControl object. For instance, you can specify the minimum allowed page header's width using the RibbonControl.PageHeaderMinWidth property, and hide the Expand/Collapse button using the RibbonControl.ShowExpandCollapseButton property.
    4. Override the Controller's OnDeactivated method and unsubscribe from the TemplateChanged event when the Controller is deactivated.

    按照以下步骤访问功能区控制对象并自定义其设置:

    1. 在 WinForms 模块的控制器文件夹中创建新的窗口控制器。

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

    3. 在模板更改事件处理程序中,确保 Frame.Template 的类型为功能区窗体。使用功能区窗体.功能区属性访问功能区控制对象。例如,可以使用功能区控制.pageHeaderMinWidth 属性指定允许的最小页页页眉宽度,并使用功能区控制.显示展开折叠按钮属性隐藏"展开/折叠"按钮。

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

     

    using System;
    using DevExpress.ExpressApp;
    using DevExpress.XtraBars.Ribbon;
    using DevExpress.Utils;
    // ...
    public class RibbonCustomizationWindowController : WindowController {
        protected override void OnActivated() {
            base.OnActivated();
            Window.TemplateChanged += Window_TemplateChanged;
        }
        private void Window_TemplateChanged(object sender, EventArgs e) {
            RibbonForm ribbonForm = Frame.Template as RibbonForm;
            if (ribbonForm != null && ribbonForm.Ribbon != null) {
                RibbonControl ribbon = ribbonForm.Ribbon;
                ribbon.PageHeaderMinWidth = 100;
                ribbon.ShowExpandCollapseButton = DefaultBoolean.False;
            }
        }
        protected override void OnDeactivated() {
            Window.TemplateChanged -= Window_TemplateChanged;
            base.OnDeactivated();
        }
    }

    Run the application to ensure that Ribbon control customizations are applied.

    运行应用程序以确保应用功能区控件自定义项。

  • 相关阅读:
    一个很实用的css3兼容工具很多属性可以兼容到IE6
    html5 canvas 填充渐变形状
    找到任何形状的中心-总结篇
    html canvas非正方旋转和缩放...写的大多是正方的有人表示一直看正方的看厌了
    把jQuery的类、插件封装成seajs的模块的方法
    那些年实用但被我忘掉javascript属性.onresize
    总有一些实用javascript的元素被人遗忘在角落-slice
    jquery(入门篇)无缝滚动
    html5 canvas旋转+缩放
    今天看到这篇新闻之后,决定休息一下咯
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Access-the-Ribbon-Control.html
Copyright © 2011-2022 走看看