Devexpress GridControl数据验证的方法
作者:互联网
向GridView里增加两个事件
1 private void gdvStruct_ValidatingEditor(object sender, BaseContainerValidateEditorEventArgs e) 2 { 3 ColumnView view = sender as ColumnView; 4 GridColumn column = (e as EditFormValidateEditorEventArgs)?.Column ?? view.FocusedColumn; 5 if (column.FieldName != "StructName") return; 6 string value = e.Value.ToString(); 7 e.Valid = Regex.IsMatch(value, @"^[\u4E00-\u9FA5a-zA-Z0-9_.]+$"); 8 } 9 10 private void gdvStruct_InvalidValueException(object sender, InvalidValueExceptionEventArgs e) 11 { 12 ColumnView view = sender as ColumnView; 13 if (view == null) return; 14 e.ExceptionMode = ExceptionMode.DisplayError; 15 e.WindowCaption = "格式错误"; 16 e.ErrorText = "只允许英文字母、数字、汉字和."; 17 view.HideEditor(); 18 }
标签:gdvStruct,return,sender,验证,Devexpress,ColumnView,private,GridControl,view 来源: https://www.cnblogs.com/east115/p/14523939.html