zoukankan      html  css  js  c++  java
  • How to: Support a Context Menu for a Custom WinForms List Editor 如何:支持自定义 WinForms 列表编辑器的上下文菜单

    In XAF applications, List Views can have context menus filled with Actions. For this purpose, the List Editor displaying a List View should support the IRequireContextMenu and IRequireDXMenuManager interfaces. This topic describes how to implement these interfaces in the WinCustomListEditor demonstrated in the How to: Implement a Custom WinForms List Editor topic.

    在 XAF 应用程序中,列表视图可以具有填充操作的上下文菜单。为此,显示列表视图的列表编辑器应支持"需要上下文菜单"和"需要DXMenuManager"接口。本主题介绍如何在 WinCustomListEditor 中实现这些接口,这些接口在"如何:实现自定义 WinForms 列表编辑器"主题中演示。

    The following image illustrates the context menu invoked for the WinCustomListEditor.

    下图说明了为 WinCustomListEditor 调用的上下文菜单。

    PopupMenuForWinThumbnailEditor

    Note 注意
    You can see the code implemented here in the FeatureCenter demo installed with XAF. This demo is located in the %PUBLIC%DocumentsDevExpress Demos 19.2ComponentseXpressApp FrameworkFeatureCenter folder by default.
    您可以在与 XAF 一起安装的功能中心演示中看到此处实现的代码。此演示位于%PUBLIC%DocumentsDevExpress Demos 19.2ComponentseXpressApp FrameworkFeatureCenter folder by default.

    To enable the context menu in a custom List Editor, modify its code in the following manner.

    要在自定义列表编辑器中启用上下文菜单,请按以下方式修改其代码。

    [ListEditor(typeof(IPictureItem))]
    public class WinCustomListEditor : ListEditor, /* ...*/ IRequireContextMenu, IRequireDXMenuManager {
        #region IRequireContextMenu Members
        private void BarManager_QueryShowPopupMenu(object sender, QueryShowPopupMenuEventArgs e) {
            if (e.Control != control) {
                e.Cancel = true;
                e.BreakShowPopupMenu = false;
            }
        }
        public void SetMenu(PopupMenu popupMenu, BarManager barManager) {
            barManager.SetPopupContextMenu(control, popupMenu);
            barManager.QueryShowPopupMenu += BarManager_QueryShowPopupMenu;
        }
            #endregion
    
            #region IRequireDXMenuManager Members
            public void SetMenuManager(IDXMenuManager menuManager) { }
            #endregion
    }

    If you implement a List Editor using a descendant of the EditorContainer control, initialize the EditorContainer.MenuManager property in the SetMenuManager method.

    如果使用编辑器容器控件的后代实现列表编辑器,则在 SetMenuManager 方法中初始化编辑器容器.MenuManager 属性。

    In the QueryShowPopupMenu event handler, you can specify whether or not to cancel showing the context menu for the current region of the control using the e.Cancel parameter. For instance, you can use the following logic for the GridView control.

    在 QueryShowPopupMenu 事件处理程序中,可以指定是否取消使用 e.Cancel 参数显示控件当前区域的上下文菜单。例如,您可以将以下逻辑用于 GridView 控件。

    GridHitTest hitTest = gridView.CalcHitInfo(gridControl.PointToClient(e.Position)).HitTest;
    e.Cancel = !(((hitTest == GridHitTest.Row) || 
        (hitTest == GridHitTest.RowCell) || (hitTest == GridHitTest.EmptyRow) || 
        (hitTest == GridHitTest.RowDetail) || (hitTest == GridHitTest.None)));
  • 相关阅读:
    开源 Serverless 里程碑:Knative 1.0 来了
    以一致的体验交付和管理云原生多集群应用
    iLogtail使用入门K8S环境日志采集到SLS
    如何在golang代码里面解析容器镜像
    mac vmware 无法复制粘贴
    使用vi编辑时上下左右方向键被转化为A、B、C、D
    left join 和 left outer join 的区别
    设计模式之 适配器模式
    设计模式之 命令模式
    设计模式学习之 策略模式
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Support-a-Context-Menu-for-a-Custom-WinForms-List-Editor.html
Copyright © 2011-2022 走看看