Private Sub ultraCalendarCombo1_ValidationError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.DateValidationErrorEventArgs) Handles ultraCalendarCombo1.ValidationError
Dim info As String = String.Empty
' Use the ErrorValue property of the DateValidationErrorEventArgs to
' get the string representation of the bad value so we can display it
' to the end user
Dim errorVal As String = "NULL"
If (Not e.ErrorValue Is Nothing) Then
errorVal = e.ErrorValue.ToString()
End If
' Use the PrevValue property of the DateValidationErrorEventArgs to
' get the string representation of the last valid value so we can display it
' to the end user
Dim prevVal As String = "NULL"
If (Not e.PreviousValue Is Nothing) Then
prevVal = e.PreviousValue.ToString()
End If
' Use the ErrorCode property of the DateValidationErrorEventArgs to determine
' what caused the validation error to occur, and translate the error code into a
' string that will be more easily understood by the end user.
Dim errorDesc As String = String.Empty
Select Case (e.ErrorCode)
Case Infragistics.Win.UltraWinSchedule.DateValidationError.AfterMaxDate
errorDesc = "The value '" + errorVal + "' is greater than the maximum allowable date (" + Me.ultraCalendarCombo1.CalendarInfo.MaxDate.ToString() + ")."
Case Infragistics.Win.UltraWinSchedule.DateValidationError.BeforeMinDate
errorDesc = "The value '" + errorVal + "' is less than the minimum allowable date (" + Me.ultraCalendarCombo1.CalendarInfo.MinDate.ToString() + ")."
Case Infragistics.Win.UltraWinSchedule.DateValidationError.NullValueNotAllowed
errorDesc = "The value must be set to a valid date."
Case Infragistics.Win.UltraWinSchedule.DateValidationError.UnableToParseValue
errorDesc = "The value '" + errorVal + "' could not be interpreted as a valid date. Please check for typographical errors."
End Select
' Build the information string that we will display in the message box
info += errorDesc + vbCrLf + vbCrLf
info += "Would you like to restore the value to the last valid value (" + prevVal + ")?" + vbCrLf
info += "If you select 'No', the value will be set to the current date."
' Display the error dialog and prompt the user to see if they want
' to restore the control's last valid value, or change the value to the
' current date instead
Dim result As DialogResult = MessageBox.Show(info, "Validation Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error)
' If the user selects 'No', then set the NewValue property of the
' DateValidationErrorEventArgs to the current date.
If (result = DialogResult.No) Then
e.NewValue = DateTime.Today
End If
End Sub