Version

ValidationError Event (UltraNumericEditorBase)

Fired when the control loses focus with an invalid Value.
Syntax
'Declaration
 
Public Event ValidationError As UltraNumericEditorBase.ValidationErrorEventHandler
Event Data

The event handler receives an argument of type Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs containing data related to this event. The following ValidationErrorEventArgs properties provide information specific to this event.

PropertyDescription
Beep  
InvalidText  
LastValidValue  
RetainFocus  
Remarks

The ValidationError event provides the ability to customize the way the control reacts when it loses focus with an invalid value.

The Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs class exposes the following properties to accomplish this:

  • Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs.Beep: When set to false, prevents the control from beeping when it loses focus with an invalid value. The default value is True.
  • Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs.RetainFocus: When set to True, the control will seize the input focus until a valid value is entered. This property can be set to False to prevent that from happening. The default value is True.
  • Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs.LastValidValue: Contains the last valid value held by the control. Useful for providing user feedback, as well as forcing the control into a valid state.

Example
This example uses the ValidationError evet to silenty restore the last valid value held by 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.

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinEditors

    Private Sub UltraNumericEditor1_ValidationError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs) Handles UltraNumericEditor1.ValidationError
        '	Set the Beep property to false to prevent the system beep
        '	sound from being generated when there is a validation error
        e.Beep = False

        '	Set the RetainFocus property to false so we don't
        '	keep the focus when there is a validation error
        e.RetainFocus = False

        '	Restore the last valid value
        Me.UltraNumericEditor1.Value = e.LastValidValue

    End Sub
using System.Diagnostics;
using Infragistics.Win;
using Infragistics.Win.UltraWinEditors;

		private void ultraNumericEditor1_ValidationError(object sender, Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs e)
		{
			//	Set the Beep property to false to prevent the system beep
			//	sound from being generated when there is a validation error
			e.Beep = false;

			//	Set the RetainFocus property to false so we don't
			//	keep the focus when there is a validation error
			e.RetainFocus = false;

			//	Restore the last valid value
			this.ultraNumericEditor1.Value = e.LastValidValue;
		}
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