[DevExpress]实现GridControl输入验证_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > [DevExpress]实现GridControl输入验证

[DevExpress]实现GridControl输入验证

 2013/8/23 14:57:13  YanZhiwei  博客园  我要评论(0)
  • 摘要:privatevoidgvWeek_ValidateRow(objectsender,DevExpress.XtraGrid.Views.Base.ValidateRowEventArgse){try{GridView_view=senderasGridView;GridColumn_optTime=_view.Columns["OptTime"];//操作时间GridColumn_no=_view.Columns["No"]
  • 标签:实现
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;//不弹出消息框
        }

注意黄色背景代码,实现效果

image

image

发表评论
用户名: 匿名