【问题标题】:Set editable property for different rows in a devexpress grid control为 devexpress 网格控件中的不同行设置可编辑属性
【发布时间】:2015-04-07 23:01:07
【问题描述】:

我有一个带有“名称”、“类”、“标记”、“等级”列的 devexpress 网格控件。现在通过查询数据库表 StudentMarks 来加载网格控件中的部分数据。通过设置相应列的 Iseditable 属性,将其余部分数据手动输入到网格控件中。我想要一个功能,使得通过查询数据库加载的条目是不可编辑的,但是网格控件中的空/空白行是可编辑的。目前我无法实现这一点,因为我的 IsEditable 对于我的 xaml 中的所有列都设置为 true。是否可以按行粒度而不是按列指定可编辑属性?

【问题讨论】:

    标签: c# wpf mvvm devexpress


    【解决方案1】:

    是的,您可以使用 gridview_ShowingEditor 事件将单元格设为只读或可编辑,将所有列的可编辑设置为 true,并在此事件中处理必须为只读的单元格。

        private void gridView1_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e) {
    
            GridView view = sender as GridView; 
    
            if(view.FocusedColumn.FieldName == "Name" || view.FocusedColumn.FieldName == "Class" 
    ||  !newRow(view, view.FocusedRowHandle))
                    e.Cancel = true;
    
        }
    

    【讨论】:

      猜你喜欢
      • 2016-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-06
      • 1970-01-01
      • 2011-12-11
      相关资源
      最近更新 更多