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