Infragistics(R) NetAdvantage(R) Windows Forms
InvalidValueBehavior Property
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace > UltraGridOverride Class : InvalidValueBehavior Property

Specifies the behavior when the user attempts to leave a cell after entering an invalid value. Default is resolved to RetainValueAndFocus.

Syntax

Visual Basic (Declaration) 
Public Property InvalidValueBehavior As InvalidValueBehavior
C# 
public InvalidValueBehavior InvalidValueBehavior {get; set;}

Example

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid


    Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ultraGrid1.InitializeLayout
        ' InvalidValueBehavior controls what happens when the user attempts to leave
        ' a cell after typing an invalid value. A value is considered to be invalid
        ' if it can't be converted to the data type of the column or if it doesn't
        ' meet the any of constraints specified on the column like the MaxValue,
        ' MinValue etc... Note: To further fine-grain the behavior hook into the
        ' CellDataError event. The associated event args exposes various properties
        ' that let you do the same as this property and in addition let you prevent
        ' the error message box from displaying.
        e.Layout.Override.InvalidValueBehavior = InvalidValueBehavior.RevertValue
    End Sub

    Private Sub UltraGrid1_CellDataError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellDataErrorEventArgs) Handles ultraGrid1.CellDataError
        ' Prevent the message box from displaying.
        e.RaiseErrorEvent = False
    End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

		private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
		{
			// InvalidValueBehavior controls what happens when the user attempts to leave
			// a cell after typing an invalid value. A value is considered to be invalid
			// if it can't be converted to the data type of the column or if it doesn't
			// meet the any of constraints specified on the column like the MaxValue,
			// MinValue etc... Note: To further fine-grain the behavior hook into the
			// CellDataError event. The associated event args exposes various properties
			// that let you do the same as this property and in addition let you prevent
			// the error message box from displaying.
			e.Layout.Override.InvalidValueBehavior = InvalidValueBehavior.RevertValue;
		}

		private void ultraGrid1_CellDataError(object sender, Infragistics.Win.UltraWinGrid.CellDataErrorEventArgs e)
		{
			// Prevent the message box from displaying.
			e.RaiseErrorEvent = false;
		}

Remarks

InvalidValueBehavior property is used to specify what actions are taken by the UltraGrid when the user attempts to leave a cell after entering an invalid value. This property provides the default values for the properties on CellDataErrorEventArgs when it fires the UltraGrid.CellDataError event. Therefore the same functionality can be achieved by hooking into that event and setting the properties on the event args. Also the event args exposes other properties that control other aspects of the behavior.

See Also