private void Grid_ValidateCell(object sender, DataGridValidationEventArgs e)
 {
     if (e.FieldName == "Quantity" && (decimal)e.NewValue <= 0)
     {
         e.ErrorContent = "The value must be positive.";
     }
 }
Exemplo n.º 2
0
 private void DataGridView_ValidateCell(object sender, DataGridValidationEventArgs e)
 {
     if (e.FieldName == "From.Name" && string.IsNullOrWhiteSpace((string)e.NewValue))
     {
         e.ErrorContent = "The From field is required.";
     }
     if (e.FieldName == "Sent" && (DateTime)e.NewValue > DateTime.Now.Date)
     {
         e.ErrorContent = "The Sent field cannot be in the future.";
     }
 }
Exemplo n.º 3
0
 private void EditForm_ValidateCell(object sender, DataGridValidationEventArgs e)
 {
     if (e.FieldName == "Quantity" && (decimal)e.NewValue <= 0)
     {
         e.ErrorContent = "The value must be positive.";
     }
     else if (e.FieldName == "Date" && (DateTime)e.NewValue > DateTime.Now.Date)
     {
         e.ErrorContent = "The date value cannot be in the future.";
     }
 }