zoukankan      html  css  js  c++  java
  • How to: Disable an Action When the Current View Has Unsaved Changes 如何:当前视图具有未保存的更改时禁用按钮

    This topic demonstrates how to disable an Action when business objects loaded to the current Object Space are changed. For this purpose, the IObjectSpace.ModifiedChanged event is handled, and the ActionBase.Enabled property is set based on the IObjectSpace.IsModified property.

    本主题演示如何在加载到当前对象空间的业务对象发生更改时禁用操作。为此,将处理 IObjectSpace.修改更改事件,并根据 IObjectSpace.IsModified 属性设置"操作基础"。

    Note 注意
    The approach described in this topic is not supported by the Mobile platform. If it is necessary to implement this scenario in your Mobile application, contact us using the Support Center
    移动平台不支持本主题中描述的方法。如果需要在移动应用程序中实施此方案,请使用支持中心与我们联系

    .

    public class ViewController1 : ViewController {
        SimpleAction action1;
        public ViewController1() {
            action1 = new SimpleAction(this, "Action1", DevExpress.Persistent.Base.PredefinedCategory.View);
        }
        protected override void OnActivated() {
            base.OnActivated();
            ObjectSpace.ModifiedChanged += ObjectSpace_ModifiedChanged;
            UpdateActionState();
        }
        void ObjectSpace_ModifiedChanged(object sender, EventArgs e) {
            UpdateActionState();
        }
        protected virtual void UpdateActionState() {
            action1.Enabled["ObjectSpaceIsModified"] = !ObjectSpace.IsModified;
        }
        protected override void OnDeactivated() {
            base.OnDeactivated();
            ObjectSpace.ModifiedChanged -= ObjectSpace_ModifiedChanged;
        }
    }

    As a result, the Action1 is grayed out in the UI when there are unsaved changes in the current View. It is impossible to execute the Action until changes are saved to a data store (e.g., using the Save Action). When the changes are saved, the Action1 reverts to its normal state.

    因此,当当前视图中存在未保存的更改时,操作 1 在 UI 中显示为灰色。在将更改保存到数据存储(例如,使用保存操作)之前,无法执行操作。保存更改后,Action1 将恢复到其正常状态。

  • 相关阅读:
    C++中函数模板template的使用
    C++中模板template和类class的结合使用
    Python中shuffle函数
    Python中利用tkinter模块构建图形用户界面GUI
    Python中怎样初始化一个类类class?
    Python中字典的has_key方法在3.4版本中改为in
    Python中怎样对数据集整体进行映射转换类型
    matlab中怎样对矩阵的某一列进行排序而使得其他列对应移动??
    Python中怎样使用shape计算矩阵的行和列
    27.反射2.md
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Disable-an-Action-When-the-Current-View-Has-Unsaved-Changes.html
Copyright © 2011-2022 走看看