DataGrid 单元格输入验证 由ValidatingEditor事件完成


private void gdv_reguline_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
        {
            int col = ((DevExpress.XtraGrid.Views.Grid.GridView)sender).FocusedColumn.AbsoluteIndex;
            if (col == 4 || col == 5)
            {
                object v = e.Value;
                int tm;
                if (v != null && (!Int32.TryParse(v.ToString(),out tm) || tm<0 )) //自定义验证逻辑
                {
                    e.Valid = false; //控制是否通过验证的开关


                    e.ErrorText = "必须输入正整数!"; //提示的验证失败的原因
                }
            }
        }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM