using DevExpress.XtraGrid.Views.Base; using DevExpress.XtraGrid.Columns; private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { ColumnView view = sender as ColumnView; GridColumn column1 = view.Columns["StartTime"]; GridColumn column2 = view.Columns["EndTime"]; //Get the value of the first column DateTime time1 = (DateTime)view.GetRowCellValue(e.RowHandle, column1); //Get the value of the second column DateTime time2 = (DateTime)view.GetRowCellValue(e.RowHandle, column2); //Validity criterion if (time1 >= time2) { e.Valid = false; //Set errors with specific descriptions for the columns view.SetColumnError(column1, "The value must be less than EndTime"); view.SetColumnError(column2, "The value must be greater than StartTime"); } } private void gridView1_InvalidRowException(object sender, DevExpress.XtraGrid.Views.Base.InvalidRowExceptionEventArgs e) { //Suppress displaying the error message box e.ExceptionMode = ExceptionMode.NoAction; }
表格输入错误提示
最新推荐文章于 2021-09-02 12:43:58 发布