A common task in developing data entry applications is to implement validation logic. Validation logic tests the end user's input for valid data. The xamDataPresenter™ control raises the EditModeEnding event when the end user is finished editing a cell. This event provides you an opportunity to inject your own custom data validation logic and cancel the cell edit if the validation fails.
Follow these steps to verify that the edited content of a cell can be parsed as an Integer.
- Before you start writing any code, you should place using/Imports directives in your code-behind so you don't need to always type out a member's fully qualified name.
In Visual Basic:
ImportsInfragistics.Windows.DataPresenter.EventsIn C#:
usingInfragistics.Windows.DataPresenter.Events;
- Wire the EditModeEnding event to xamDataPresenter.
In XAML:
<igDP:XamDataPresenterx:Name="XamDataPresenter1" ...EditModeEnding="XamDataPresenter1_EditModeEnding"/>
- Create the event handler method in your code-behind.
In Visual Basic:
SubXamDataPresenter1_EditModeEnding(ByValsenderAs Object, _ByValeAsEditModeEndingEventArgs)End SubIn C#:
voidXamDataPresenter1_EditModeEnding(objectsender, EditModeEndingEventArgs e) { }
Notice the method receives the EditModeEndingEventArgs parameter which provides properties containing information specific to edited cell data.
- Add your validation logic to the event handler. Verify the edited content of a cell can be parsed as an Integer. If the parse fails, the program rejects the changes using the AcceptChanges property and notifies the end user of the validation failure with a MessageBox.
In Visual Basic:
SubXamDataPresenter1_EditModeEnding(ByValsenderAs Object, _ByValeAsEditModeEndingEventArgs)' Try to parse the data to see if its validDimvalueAs IntegerIf NotInt32.TryParse(e.Editor.Text, value)Then' If the parse fails, reject the changese.AcceptChanges =FalseMessageBox.Show("Data Validation Failed. Must enter an Integer") e.Cancel =TrueEnd IfEnd SubIn C#:
voidXamDataPresenter1_EditModeEnding(objectsender, EditModeEndingEventArgs e) {// Try to parse the data to see if its validintvalue;if(!Int32.TryParse(e.Editor.Text,outvalue)) {// If the parse fails, reject the changese.AcceptChanges =false; MessageBox.Show("Data Validation Failed. Must enter an Integer"); e.Cancel =true; } }
- Build and run the project. When you enter data that is not of type Integer into any Field, you will be prompted with a MessageBox.

Accessing Cell Values in the Active Record
Accessing Cell Values in xamDataPresenter's RecordActivated Event
Changing Field, Record, or Cell Selection Behavior
Default Editor Types for Different Data Types
Enumerating Rows and Columns Using the FieldLayoutInitialized Event
Setting a ComboBox for Use in a Field
Specify a ValueEditor for a Field in xamDataPresenter
