Hi,
I do the validation on BeforeExitEditMode and keep the focus in cell if it the condition is not true. I want to restore the value of the cell if valid criteria is not met. My code is below:-
Dim result As DialogResult
If e.CancellingEditOperation Then Return
'check code column and check if there is some value in it
aCell = UltraGrid1.ActiveCell
If (aCell.Column.Key = "Code") And Not (DBNull.Value.Equals(aCell.Text)) Then
'do validation here
If aCell.Text = "9" Then
If e.ForceExit Then
' If the UltraGrid must exit the edit mode, then cancel the
' cell update so the original value gets restored in the cell.
Return
End If
If result = Windows.Forms.DialogResult.Yes Then
aCell.SelectAll()
CodeIsInValid = True
e.Cancel = True
End Sub
Is there any way to achieve this?
Thanks in advance,
Parv
Try this: to cancel the update.
Private Sub yourUltraGrid_BeforeCellUpdate(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeCellUpdateEventArgs) Handles ultraGrid1.BeforeCellUpdate ' You may update the if statement to match your logic If GetType(e.NewValue) != GetType(int) Then e.Cancel = true; MsgBox("Only integers are allowed in this field."); End IfEnd Sub
Private Sub yourUltraGrid_BeforeCellUpdate(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeCellUpdateEventArgs) Handles ultraGrid1.BeforeCellUpdate
' You may update the if statement to match your logic If GetType(e.NewValue) != GetType(int) Then e.Cancel = true; MsgBox("Only integers are allowed in this field."); End IfEnd Sub