class="csharpcode"> private void gvWeek_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { try { GridView _view = sender as GridView; GridColumn _optTime = _view.Columns["OptTime"];//操作时间 GridColumn _no = _view.Columns["No"];//序号 GridColumn _optStatusStr = _view.Columns["OptStatusStr"];//操作状态 DateTime _dtOptTime = default(DateTime); int _nNo = (int)_view.GetRowCellValue(e.RowHandle, _no); string _sOptTime = string.Empty; if (DateTime.TryParse(_view.GetRowCellValue(e.RowHandle, _optTime).ToString(), out _dtOptTime)) { e.Valid = CheckOpTimeIsLegal(_dtOptTime, _nNo);//判断修改的操作时间是否合法 if (!e.Valid) { _view.SetColumnError(_optTime, "须大于之前所配置时间,请检查!"); } else { _view.ClearColumnErrors(); _sOptTime = _dtOptTime.ToString("HH:mm"); } } string _sOpStatusStr = _view.GetRowCellValue(e.RowHandle, _optStatusStr).ToString(); int _nOpStatus = ProcessOpStatusStrToValue(_sOpStatusStr); ProcessUpdateCtuChWeekPlan(_nNo, string.Empty, _nOpStatus, _sOpStatusStr); } catch (Exception ex) { onInvokeLog(CreateLog(string.Format("更新周表配置失败,原因:{0}.", ex.Message.Trim()), LogType.ClientException)); } }
private void gvWeek_InvalidRowException(object sender, DevExpress.XtraGrid.Views.Base.InvalidRowExceptionEventArgs e) { e.ExceptionMode = ExceptionMode.NoAction;//不弹出消息框 }
注意黄色背景代码,实现效果