Version

EditError Event

Occurs when the end user has entered invalid data during an edit mode session and attempted to exit edit mode.
Syntax
'Declaration
 
Public Event EditError As EditErrorEventHandler
public event EditErrorEventHandler EditError
Event Data

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

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
DisplayMessageBox Gets/sets whether a MessageBox is displayed to the end user. By default, the property returns true, and a MessageBox is displayed to the end user; set the property to false to prevent it from displaying.
Editor Returns the EmbeddableEditorBase-derived editor that is currently in edit mode.
ErrorText Gets/sets the text which contains the error message that is displayed to the end user.
Item (Inherited from Infragistics.Win.UltraWinListView.CancelableItemEventArgs)Returns the UltraListViewItem with which this instance is associated.
RestoreOriginalValue Gets/sets whether the item's value will be restored to the value it had prior to entering edit mode.
StayInEditMode Gets/sets whether the item will remain in edit mode, preventing the end user from leaving the item until a valid value is entered or the edit mode session is canceled.
Example
The following code sample demonstrates how to handle the UltraListView's EditError event to provide additional information to the end user:

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.UltraWinListView


    Private Sub ultraListView1_EditError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.EditErrorEventArgs) Handles ultraListView1.EditError
        '	Set the 'DisplayMessageBox' property to false so that
        '	the default MessageBox does not appear
        e.DisplayMessageBox = False

        '	Show a MessageBox with some additional information about the error
        Dim message As String = String.Format("The value '{0}' is not valid. Would you like to revert to the last valid value?", e.Editor.CurrentEditText)
        Dim result As DialogResult = MessageBox.Show(message, "Invalid value entered", MessageBoxButtons.YesNo, MessageBoxIcon.Information)

        '	If the user elected to revert to the original value,
        '	set the 'RestoreOriginalValue' property to true
        If result = DialogResult.Yes Then
            e.RestoreOriginalValue = True
            e.StayInEditMode = False
        Else
            e.RestoreOriginalValue = False
            e.StayInEditMode = True
        End If

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


		private void ultraListView1_EditError(object sender, Infragistics.Win.UltraWinListView.EditErrorEventArgs e)
		{
			//	Set the 'DisplayMessageBox' property to false so that
			//	the default MessageBox does not appear
			e.DisplayMessageBox = false;

			//	Show a MessageBox with some additional information about the error
			string message = string.Format( "The value '{0}' is not valid. Would you like to revert to the last valid value?", e.Editor.CurrentEditText );
			DialogResult result = MessageBox.Show( message, "Invalid value entered", MessageBoxButtons.YesNo, MessageBoxIcon.Information );

			//	If the user elected to revert to the original value,
			//	set the 'RestoreOriginalValue' property to true
			if ( result == DialogResult.Yes )
			{
				e.RestoreOriginalValue = true;
				e.StayInEditMode = false;
			}
			else
			{
				e.RestoreOriginalValue = false;
				e.StayInEditMode = true;
			}
		}
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