Version

StayInEditMode Property

Indicates whether to stay in edit mode. Default value is true.
Syntax
'Declaration
 
Public Property StayInEditMode As Boolean
public bool StayInEditMode {get; set;}
Remarks

If StayInEditMode is true, then the cell won't exit the edit mode unless the ForceExit is true in which case the cell will exit the edit mode regardless.

Example
Following code shows some of the information available in CellDataError event and the event's potential uses.

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

  Private Sub UltraGrid1_CellDataError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellDataErrorEventArgs) Handles ultraGrid1.CellDataError

      ' CellDataError gets fired when the user attempts to exit the edit mode
      ' after entering an invalid value in the cell. There are several properties
      ' on the passed in event args that you can set to control the UltraGrid's
      ' behaviour.

      ' Typically ForceExit is false. The UltraGrid forces exits on cells under
      ' circumstances like when it's being disposed of. If ForceExit is true, then 
      ' the UltraGrid will ignore StayInEditMode property and exit the cell 
      ' restoring the original value ignoring the value you set to StayInEditMode
      ' property.
      If Not e.ForceExit Then
          ' Default for StayInEditMode is true. However you can set it to false to
          ' cause the grid to exit the edit mode and restore the original value. We
          ' will just leave it true for this example.
          e.StayInEditMode = True

          ' Set the RaiseErrorEvent to false to prevent the grid from raising 
          ' the error event and displaying any message.
          e.RaiseErrorEvent = False

          ' Instead display our own message.
          If Me.ultraGrid1.ActiveCell.Column.DataType Is GetType(DateTime) Then
              MessageBox.Show(Me, "Please enter a valid date.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error)
          ElseIf Me.ultraGrid1.ActiveCell.Column.DataType Is GetType(Decimal) Then
              MessageBox.Show(Me, "Please enter a valid numer.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error)
          End If
      Else
          ' Set the RaiseErrorEvent to false to prevent the grid from raising 
          ' the error event.
          e.RaiseErrorEvent = False
      End If

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_CellDataError(object sender, Infragistics.Win.UltraWinGrid.CellDataErrorEventArgs e)
{

	// CellDataError gets fired when the user attempts to exit the edit mode
	// after entering an invalid value in the cell. There are several properties
	// on the passed in event args that you can set to control the UltraGrid's
	// behaviour.

	// Typically ForceExit is false. The UltraGrid forces exits on cells under
	// circumstances like when it's being disposed of. If ForceExit is true, then 
	// the UltraGrid will ignore StayInEditMode property and exit the cell 
	// restoring the original value ignoring the value you set to StayInEditMode
	// property.
	if ( !e.ForceExit )
	{
		// Default for StayInEditMode is true. However you can set it to false to
		// cause the grid to exit the edit mode and restore the original value. We
		// will just leave it true for this example.
		e.StayInEditMode = true;
	    
		// Set the RaiseErrorEvent to false to prevent the grid from raising 
		// the error event and displaying any message.
		e.RaiseErrorEvent = false;

		// Instead display our own message.
		if ( this.ultraGrid1.ActiveCell.Column.DataType == typeof( DateTime ) )
		{
			MessageBox.Show( this, "Please enter a valid date.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error );
		}
		else if ( this.ultraGrid1.ActiveCell.Column.DataType == typeof( decimal ) )
		{
			MessageBox.Show( this, "Please enter a valid numer.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error );
		}
	}
	else
	{
		// Set the RaiseErrorEvent to false to prevent the grid from raising 
		// the error event.
		e.RaiseErrorEvent = 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