通过验证更改GridView中的单元格

时间:2011-04-14 15:29:42

标签: winforms gridview .net-4.0 devexpress cell

我有一个GridView我希望当我更改一个单元格以查看它的新值是否由我的函数ValidateValue(string aValue)有效并且是否有效时 - 将新值和旧值存储为Struct S {string old,new};中的一对怎么做?

1 个答案:

答案 0 :(得分:2)

为此目的处理GridView Validate Cell事件。以下是一些示例代码,展示了如何获取新的和旧的编辑值:

private void gridView1_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e) {
    BaseEdit edit = (sender as GridView).ActiveEditor;
    object oldValue = edit.OldEditValue;
    object newValue = e.Value;
}