We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

restoring original value on validation failure

I''m using a custom control, and if my validation fails, I want to restore the original value, but am having no luck. I think the problem is that the control text never gets into the grid. I''ve attempted to set it, but it doesn''t "stick" _ I''m thinking I should be doing this elsewhere..but where? I tried SaveCellInfo - didn''t work for me. Here''s what I''ve got in CurrentCellValidating: With grdInsertDataOptions colIndex = .CurrentCell.ColIndex rowIndex = .CurrentCell.RowIndex If String.Compare(.Item(rowIndex, colIndex).CellType, "Control", True) = 0 Then newValue = .CurrentCell.Renderer.Control.Text oldValue = .Item(rowIndex, colIndex).Text If newValue = "blah" Then .CurrentCell.Renderer.Control.Text = oldValue e.Cancel = True MessageBox.Show("Invalid Entry") Else .Item(rowIndex, colIndex).Text = newValue e.Cancel = False End If End If End With

2 Replies

AD Administrator Syncfusion Team May 22, 2006 05:56 AM UTC

Hi Jenny, You can use this code to get the oldvalue of the control cell in a grid using CurrentCellStartEditing event. Here is a code snippet. Private oldvalue As String = String.Empty Private Sub gridDataBoundGrid1_CurrentCellStartEditing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles gridDataBoundGrid1.CurrentCellStartEditing Dim cc As GridCurrentCell =Me.gridDataBoundGrid1.CurrentCell If cc.RowIndex = 1 AndAlso cc.ColIndex = 1 Then oldvalue = cc.Renderer.Control.Text End If End Sub Please let me know if this helps. Best Regards, Haneef


AD Administrator Syncfusion Team May 23, 2006 07:16 PM UTC

Hi, That did the trick. Thanks for helping with my synconfusion... Would be nice if there was some sort of document describing when and the order of the grid events firing. Thanks, Jenny >Hi Jenny, > >You can use this code to get the oldvalue of the control cell in a grid using CurrentCellStartEditing event. Here is a code snippet. > >Private oldvalue As String = String.Empty > >Private Sub gridDataBoundGrid1_CurrentCellStartEditing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles gridDataBoundGrid1.CurrentCellStartEditing > Dim cc As GridCurrentCell =Me.gridDataBoundGrid1.CurrentCell > If cc.RowIndex = 1 AndAlso cc.ColIndex = 1 Then > oldvalue = cc.Renderer.Control.Text > End If >End Sub > >Please let me know if this helps. >Best Regards, >Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon