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

What event to use when changes are made in textbox cell type

I can use CurrentCellValidating but the problem is this: If I have a cell with CellValueType of float and user enters "ABC", the grid control will popup a message box reading "ABC is not a valid value for Single." This is what I want but it calls CurrentCellValidating first, where I erronously save "ABC", and then it validates the value and popup the message box. I want grid control to validate the value for me and only send the callback if the value is valid. How can I do this?

6 Replies

AD Administrator Syncfusion Team September 8, 2004 02:12 PM

Try storing the value in CurrentCellChanged event. Ken


AD Administrator Syncfusion Team September 8, 2004 03:01 PM

In CurrentCellValidating, set a module level member equal to the new value. Then in CurrentCellMoved, check this module level variable to see if it is not null. If it is not, you can save it there. To find out the old cell location, use grid.CurrentCell.MoveFromRowIndex\ColIndex. After saving it, set the variable to null so it will not trigger another save until it is reset in CurrentCellValidating.


AD Administrator Syncfusion Team September 8, 2004 03:04 PM

Thanks for the suggestion. However, this event is triggered on every keystroke from the user and is not what I''m looking for. >Try storing the value in CurrentCellChanged event. > >Ken


AD Administrator Syncfusion Team September 8, 2004 03:20 PM

Try the combination of CurrentCellValidating and CurrentMoved that I suggested above.


AD Administrator Syncfusion Team September 8, 2004 03:33 PM

Yes, this works, but if the user 1. user enters "ABC" and hits Enter or Tab 2. CurrentCellMoved is called and variable is set to "ABC" 3. user gets the error message box 4. user hits ESC to cancel his change 5. user clicks Enter or Tab key 6. CurrentCellMoved is called and I erroneously save "ABC". Is there another way? >In CurrentCellValidating, set a module level member equal to the new value. > >Then in CurrentCellMoved, check this module level variable to see if it is not null. If it is not, you can save it there. To find out the old cell location, use grid.CurrentCell.MoveFromRowIndex\ColIndex. After saving it, set the variable to null so it will not trigger another save until it is reset in CurrentCellValidating.


AD Administrator Syncfusion Team September 8, 2004 03:49 PM

>>1. user enters "ABC" and hits Enter or Tab 2. CurrentCellMoved is called and variable is set to "ABC" 3. user gets the error message box << If the user gets an error message, then CurrentCellMoved should not be hit (as the currentcell did not move). I tried this in a sample, it seems to work this way using version 2.1.0.9 for me. In this situation, in a GridDataBoundGrid, the ValidateFailed event should be hit (or in a GridControl, CurrentCellMovedFailed should be hit). You could reset your module member to null in one of these failed event handlers. But if the user sees an error message, the default behavior is not to move the currentcell so CurrentCellMoved should not be hit. Now CurrentCellMoving will be hit, but CurrentCellMoved should not.

Loader.
Live Chat Icon For mobile
Up arrow icon