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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

restoring original value on validation failure

Thread ID:

Created:

Updated:

Platform:

Replies:

44319 May 19,2006 09:05 PM UTC May 23,2006 07:16 PM UTC WinForms 2
loading
Tags: GridControl
Jenny Wilson
Asked On May 19, 2006 09:05 PM UTC

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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;