數據輸入錯誤提示

using DevExpress.XtraEditors.Controls;

private void dateEdit1_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
   DateTime currentValue = (sender as DateEdit).DateTime;
   if(currentValue.Month != DateTime.Today.Month || currentValue.Year != DateTime.Today.Year)
      e.Cancel = true;
}

private void dateEdit1_InvalidValue(object sender, InvalidValueExceptionEventArgs e) {
   e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.NoAction;
   MessageBox.Show("Enter a date within the current month.", "Error");
}
發佈了22 篇原創文章 · 獲贊 11 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章