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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

18759 Sep 8,2004 05:54 PM UTC Sep 8,2004 07:49 PM UTC WinForms 6
loading
Tags: GridControl
James Tran
Asked On September 8, 2004 05:54 PM UTC

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?

Administrator [Syncfusion]
Replied On September 8, 2004 06:12 PM UTC

Try storing the value in CurrentCellChanged event. Ken

Administrator [Syncfusion]
Replied On September 8, 2004 07:01 PM UTC

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.

Administrator [Syncfusion]
Replied On September 8, 2004 07:04 PM UTC

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

Administrator [Syncfusion]
Replied On September 8, 2004 07:20 PM UTC

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

Administrator [Syncfusion]
Replied On September 8, 2004 07:33 PM UTC

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.

Administrator [Syncfusion]
Replied On September 8, 2004 07:49 PM UTC

>>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.

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

;