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

CurrentCellAcceptedChanges not invoked again after bad input

I am validing cell input with an event handler connected to the CurrentCellAcceptedChanges event. When I trap bad input, I display a message and then set e.Cancel to true and return. The cell correctly stays in "edit mode", but if the user just pressed the tab key without making any corrections to the input, the grid just activates the next cell, it does not re-fire the CurrentCellAcceptedChanges event. This means the bad input is kept in that case. Is there some other property that must be set in my event handler so the grid know it has to refire the event after a failed validation?

5 Replies

AD Administrator Syncfusion Team August 18, 2005 11:02 PM UTC

You should try using CurrentCellValidating to validate the your user''s input.


AD Administrator Syncfusion Team August 22, 2005 02:25 PM UTC

CurrentCellValidating is not being invoked for me if the cell is activated, but not in editmode. i.e. I have my grid setup to function like excel--click on a cell, start to type just replaces the text, then tab. CurrentCellValidating is not invoked. If I dbl click the cell or press F2 to put it into edit mode, then the CurrentCellValidating is called, but if I press esc to stop the edit I can tab to the next cell, even though bad data exists in the cell. >You should try using CurrentCellValidating to validate the your user''s input.


AD Administrator Syncfusion Team August 22, 2005 02:42 PM UTC

CurrentCellValidating should be hit anytime your user makes a change in the cell (and does not cancel the change by pressing escape which should restore the cell to the original valid state). How do I see the problem you are having in this sample? Are you handling events or have other property setting that might be inteferring with the standard behavior of the grid? Or am I missing something? http://www.syncfusion.com/Support/user/uploads/GDBG_1a963169.zip


AD Administrator Syncfusion Team August 22, 2005 09:56 PM UTC

The following CurrentCellDeactivating handler is the problem. I had added the following handler based on your previous responses on how to make a right click not activate the current cell. I want excel-like behavior where rt click just brings up the context menu w/o activating the current cell. When this handler is in place the CurrentCellValidating handler is not called when tabbing from an active, but not editing cell. private void TheGrid_CurrentCellDeactivating(object sender, CancelEventArgs e) { if(_lockForForMouseUp) { e.Cancel = true; _lockForForMouseUp = false; } else if(Control.MouseButtons == MouseButtons.Right) { int row, col; Point pt = this.gridDataBoundGrid1.PointToClient(Control.MousePosition); if(this.gridDataBoundGrid1.PointToRowCol(pt, out row, out col) && this.gridDataBoundGrid1.Selections.Ranges.AnyRangeContains(GridRangeInfo.Cell(row, col))) { e.Cancel = true; _lockForForMouseUp = true; } } } >CurrentCellValidating should be hit anytime your user makes a change in the cell (and does not cancel the change by pressing escape which should restore the cell to the original valid state). > >How do I see the problem you are having in this sample? Are you handling events or have other property setting that might be inteferring with the standard behavior of the grid? Or am I missing something? >http://www.syncfusion.com/Support/user/uploads/GDBG_1a963169.zip >


AD Administrator Syncfusion Team August 22, 2005 10:07 PM UTC

>>when tabbing from an active, but not editing cell. What does this mean? CurrentCellValidating should be hit when you leave the cell only if the cell was modified by the user. The cell being acive (showing an edit cursor) is not sufficient to trigger the event. Is this the case you are trying to catch, when you leave an active, unchanged cell?

Loader.
Live Chat Icon For mobile
Up arrow icon