Version

DateValidationErrorEventArgs Class

Event Args for the ValidationError event of the UltraCalendarCombo
Syntax
'Declaration
 
Public Class DateValidationErrorEventArgs 
   Inherits System.EventArgs
public class DateValidationErrorEventArgs : System.EventArgs 
Example
This example uses the ValidationError event to display a detailed message to the end user when an invalid value has been typed into the edit portion of the control.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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
private void ultraCalendarCombo1_ValidationError(object sender, Infragistics.Win.UltraWinSchedule.DateValidationErrorEventArgs e)
{

	string info = 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
	string errorVal = "NULL";
	if ( e.ErrorValue != null )
		errorVal = e.ErrorValue.ToString();

	//	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
	string prevVal = "NULL";
	if ( e.PreviousValue != null )
		prevVal = e.PreviousValue.ToString();

	//	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.
	string errorDesc = string.Empty;
	switch ( e.ErrorCode )
	{
		case Infragistics.Win.UltraWinSchedule.DateValidationError.AfterMaxDate:
		{
			errorDesc = "The value '" + errorVal + "' is greater than the maximum allowable date (" + this.ultraCalendarCombo1.CalendarInfo.MaxDate.ToString() + ").";
			break;
		}
		case Infragistics.Win.UltraWinSchedule.DateValidationError.BeforeMinDate:
		{
			errorDesc = "The value '" + errorVal + "' is less than the minimum allowable date (" + this.ultraCalendarCombo1.CalendarInfo.MinDate.ToString() + ").";
			break;
		}
		case Infragistics.Win.UltraWinSchedule.DateValidationError.NullValueNotAllowed:
		{
			errorDesc = "The value must be set to a valid date.";
			break;
		}
		case Infragistics.Win.UltraWinSchedule.DateValidationError.UnableToParseValue:
		{
			errorDesc = "The value '" + errorVal + "' could not be interpreted as a valid date. Please check for typographical errors.";
			break;
		}
	}	//	END switch

	//	Build the information string that we will display in the message box
	info += errorDesc + "\n" + "\n";
	info += "Would you like to restore the value to the last valid value (" + prevVal + ")?" + "\n";
	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
	DialogResult result = 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 )
		e.NewValue = DateTime.Today;

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also