Version

MaskValidationError Event

Occurs when the text of the control fails mask validation.
Syntax
'Declaration
 
Public Event MaskValidationError As UltraMaskedEdit.MaskValidationErrorEventHandler
public event UltraMaskedEdit.MaskValidationErrorEventHandler MaskValidationError
Event Data

The event handler receives an argument of type MaskValidationErrorEventArgs containing data related to this event. The following MaskValidationErrorEventArgs properties provide information specific to this event.

PropertyDescription
Beep you can set this property to false to prevent the masked edit from beeping.
Message Returns a brief message indicating why the validation failed.
RetainFocus Set this to true to force the masked edit to retain the focus when the user tries to change the focus to a different control when the entered text does not satisify the mask. Set it to false to alter this default behaviour.
Revert if you set this to true, the text in the MaskedEdit will be reverted back to the original text.
Remarks
When the control loses the input focus, it verifies whether the text in the control satisfies the input mask. If text input does not match the mask at any point, the MaskValidationError event will occur. This event can also occur after text has been pasted into the MaskedEdit control.
Example
Follwoing code shows properties available in MaskValidationError event of the masked edit.

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.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinMaskedEdit

  Private Sub UltraMaskedEdit1_MaskValidationError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinMaskedEdit.MaskValidationErrorEventArgs) Handles ultraMaskedEdit1.MaskValidationError
      ' MaskValidationError gets fired when the user tries to move the focus away from the
      ' masked edit while the masked edit has an invalid input.

      Debug.WriteLine("MaskValidationError fired.")

      If Not e.Message Is Nothing Then
          Debug.WriteLine("Error message = " & e.Message)
      End If

      ' Set the Beep to false to prevent the masked edit from beeping which it does
      ' by default.
      e.Beep = False

      ' Set the RetainFocus to false to prevent it from retaining focus which it does
      ' by default.
      e.RetainFocus = False
  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinMaskedEdit;
using System.Diagnostics;

private void ultraMaskedEdit1_MaskValidationError(object sender, Infragistics.Win.UltraWinMaskedEdit.MaskValidationErrorEventArgs e)
{
	// MaskValidationError gets fired when the user tries to move the focus away from the
	// masked edit while the masked edit has an invalid input.

	Debug.WriteLine( "MaskValidationError fired." );

	if ( null != e.Message )
	{
		Debug.WriteLine( "Error message = " + e.Message );
	}

	// Set the Beep to false to prevent the masked edit from beeping which it does
	// by default.
	e.Beep = false;
	
	// Set the RetainFocus to false to prevent it from retaining focus which it does
	// by default.
	e.RetainFocus = false;
}
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