【问题标题】:Janus GridEX: Cannot get the newly edited value on CellValueUpdated eventJanus GridEX:无法在 CellValueUpdated 事件中获取新编辑的值
【发布时间】:2017-01-28 00:08:47
【问题描述】:

处理时如何获取当前编辑的值:

public class GridEX // ...
{
    // ... 
    public event ColumnActionEventHandler CellValueChanged;
    // ...
};

尝试使用以下方法获取值:

GridEXCell valueChangedCell = _gridView.CurrentRow.Cells[<desired_column_index>];
object rawValue = valueChangedCell.Value;
// or even with
string rawValue = valueChangedCell.Text;

valueChangedCell 的值发生更改的唯一时刻是触发 CellUpdatedUpdatingCell 事件时。但是后两者仅在用户将键盘输入焦点更改到另一个单元格的情况下才会触发,这可能是为了应用已编辑单元格的新值。我要查找其值的单元格是一个仅包含一个复选框的单元格。我想在给定单元格的复选框切换后立即执行给定操作,而不是在用户更改焦点后立即执行,例如移动到表格中的另一个单元格。看到在事件的描述中提到了一些行缓冲区:

[Description("Occurs after changes in a cell are copied into the row's buffer.")]
public event ColumnActionEventHandler CellUpdated;

[Description("Occurs before updating the changes in a cell to the row's buffer")]
public event UpdatingCellEventHandler UpdatingCell;

我认为复选框的当前值可能保存在某个缓冲区中,并且在更改焦点后,新值将应用于单元格。

任何想法如何在处理 Janus 的GridEX.CellValueChanged 时获取复选框的当前设置值?

【问题讨论】:

    标签: c# janus gridex


    【解决方案1】:

    我修复了添加在以下事件中触发的方法的问题:private void

    CloseEditMode() 
    { 
       gridRubrica.AllowEdit = InheritableBoolean.False; 
       gridRubrica.AllowEdit = InheritableBoolean.True; 
    } 
    
    private void gridRubrica_CellValueUpdated(object sender, ColumnActionEventArgs e) 
    { 
       if (e.Column.Key.Equals("Selected")) { CloseEditMode(); } 
    } 
    

    【讨论】:

      【解决方案2】:

      聚会有点晚了,但由于我遇到了同样的困难,我决定在 Cell Changed 是 CheckBox 时刷新待处理的更改

      private void gridEX1_CellChanged(object sender, ColumnActionEventArgs e)
      {
          if (e.Column.ColumnType == ColumnType.CheckBox)
          {
              gridEX1.UpdateData(); // Flush any pending changes
          }
      }
      

      这将触发另一个处理验证的处理程序(在我的例子中)

      【讨论】:

      • 这对我不起作用,因为当您不更改正在更新的行的焦点时,模型不会更新。我修复了添加在以下事件中触发的方法的问题: private void CloseEditMode() { gridRubrica.AllowEdit = InheritableBoolean.False; gridRubrica.AllowEdit = InheritableBoolean.True; } private void gridRubrica_CellValueUpdated(object sender, ColumnActionEventArgs e) { if (e.Column.Key.Equals("Selected")) { CloseEditMode(); } }
      • 哈哈!我又遇到了这个问题,我找到了自己的解决方案!谢谢你过去的我!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-01
      相关资源
      最近更新 更多