zoukankan      html  css  js  c++  java
  • How to: Detect a Lookup List View in Code 如何:在代码中检测查找列表视图

    This topic demonstrates how to check if the current View is a Lookup List View. This can be useful if you want to customize Lookups only, for instance, to hide the New Action displayed below the Lookup List View.

    本主题演示如何检查当前视图是否为查找列表视图。如果只想自定义"查找"(例如,以隐藏"查找列表"视图下方显示的"新建操作"),则此功能非常有用。

    Note 注意
    Mobile applications do not have a specific template for Lookup List Views and do not support the approach described in this topic.
    移动应用程序没有用于查找列表视图的特定模板,并且不支持本主题中描述的方法。

    Implement a View Controller that targets List Views only and override the OnActivated method. Check that the Frame.Context value is LookupControl or LookupWindow. If the condition is true, this means that the current List View is a Lookup List View.

    实现仅面向列表视图的视图控制器并覆盖 On"已激活"方法。检查 Frame.上下文值是查找控制还是查找窗口。如果条件为 true,则表示当前列表视图是"查找列表视图"。

    You can now, for example, deactivate the New Action in all Lookups. Use the Frame.GetController<ControllerType> method to get the NewObjectViewController and then use the NewObjectViewController.NewObjectAction property to access the New Action.

    例如,您现在可以在所有查找中停用"新操作"。使用 Frame.GetController<ControllerType> 方法获取 NewObjectView 控制器,然后使用 NewObjectView 控制器.NewObjectAction 属性访问"新建操作"。

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.SystemModule;
    // ...
    public class DeactivateNewActionInLookupsController : ViewController<ListView> {
        protected override void OnActivated() {
            base.OnActivated();
            if (Frame.Context == TemplateContext.LookupControl || Frame.Context == TemplateContext.LookupWindow) {
                NewObjectViewController controller = Frame.GetController<NewObjectViewController>();
                if (controller != null) {
                    controller.NewObjectAction.Active.SetItemValue("LookupListView", false);
                }
            }
        }
    }

    Run a WinForms or ASP.NET application to ensure that the New Action is deactivated in all Lookup List Views.

    运行 WinForms 或ASP.NET应用程序,以确保在所有查找列表视图中停用"新操作"。

    You can also detect a Lookup List View by its View.Id: all Lookup List Views have identifiers with the "_LookupListView" suffix by default. However, this also detects Views that were initially designed as Lookups, but are not used as Lookups.

    您还可以按其View.Id检测查找列表视图:默认情况下,所有查找列表视图都有带有"_LookupListView"后缀的标识符。但是,这还会检测最初设计为查找但未用作查找的视图。

    Tip 提示
    If you want to hide the New Action for a particular Lookup List View, find the corresponding View node in the Model Editor and set the IModelView.AllowNew property to false.

    如果要隐藏特定查找列表视图的"新建操作",请在模型编辑器中查找相应的视图节点,并将 IModelView.AllowNew 属性设置为 false。

  • 相关阅读:
    沟通是项目管理知识体系中的九大知识领域之一
    项目管理的三要素时间、成本、质量
    项目管理提升效率的几大关键点
    收到FRDMKL02Z
    【转】arm 开发工具比较(ADS vs RealviewMDK vs RVDS)
    你不能自己把自己放弃写在毕业季
    【转】为什么你应该(从现在开始就)写博客
    Vivado 2014.4 FFT IP 使用及仿真
    项目需求的一些事
    娇荣电子工作室成立了
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Detect-a-Lookup-List-View-in-Code.html
Copyright © 2011-2022 走看看