I am using 22.214.171.124 Syncfusion databound grid on win2k/VS.NET 2003. I have my own cell model/renderer derived from text box cell model. When CurrentCellAcceptedChanges event occurs (when I enter a new value and hit enter) for that cell, I am changing lot of values in the grid cells. I am getting the following exception now.
Can you help me out.
Exception stack trace:
Do not move current position with this method!
at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.SyncCurrentRecordState(Int32 pos)
at Syncfusion.Windows.Forms.Grid.GridDataBoundGrid.OnCurrentCellActivated(EventArgs e)
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.Activate(Int32 rowIndex, Int32 colIndex, GridSetCurrentCellOptions options)
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.MoveTo(Int32 rowIndex, Int32 colIndex, GridSetCurrentCellOptions options, Boolean discardChanges)
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.MoveTo(Int32 rowIndex, Int32 colIndex, GridSetCurrentCellOptions options)
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.InternalMove(GridDirectionType direction, Int32 num, GridSetCurrentCellOptions options)
at Syncfusion.Windows.Forms.Grid.GridInternal.GridSelectCellsMouseController.GridCurrentCellExternalMove(GridDirectionType direction, Int32 num, Boolean extendSelection)
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.Move(GridDirectionType direction, Int32 num, Boolean extendSelection, Boolean wrapCell)
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.Move(GridDirectionType direction, Int32 num, Boolean extendSelection)
at Syncfusion.Windows.Forms.Grid.GridCurrentCell.MoveRight(Int32 num, Boolean extendSelection)
at Syncfusion.Windows.Forms.Grid.GridControlBase.ProcessDialogKey(Keys key)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Safertek.UFactory.Client.ClientStarter.Main(String args) in C:\dev\UFactory\UFactory.Client\Client\ClientStarter.cs:line 49
ADAdministrator Syncfusion Team October 28, 2003 03:31 PM
That stack trace doesn't indicate that OnCurrentCellAcceptedChanges was hit so I am not sure if this helps.
But, in general when you do some changes to the grid while within a current cell event, the CurrentCell.Lock() and CurrentCell.Unlock() calls often help. So, that would be the first thing to try to call CurrentCell.Lock() before you start changing cells and CurrentCell.Unlock() afterwards.
ADAdministrator Syncfusion Team October 28, 2003 03:59 PM
I wrapped my dataBoundGrid_CurrentCellAcceptedChanges() method between cc.Lock() and cc.Unlock(). No luck. It still gives me the same exception.
Otherthing is, when I am tabbing through the cells in a row, grid fires CurrentCellChanged() event even though I really did not change anything. Is there another event that will get fired only when I modify the actual cell value e.g. updating price from 1.0 to 2.0.
ADAdministrator Syncfusion Team October 29, 2003 08:53 AM
Is dataBoundGrid_CurrentCellAcceptedChanges being hit before the exception? (Just making sure ...)
Another idea: What if you call Binder.DirectSaveCellInfo = true; before making changes and binder.DirectSaveCellInfo = false;
When you set a breakpoint in your handler of CurrentCellChanged, you could check out the call stack and identify the method in your renderer that caused the call to CurrentCellChanged. CurrentCellChanged should only get raised when the user edits the cell.
ADAdministrator Syncfusion Team October 29, 2003 12:01 PM
Setting DirectSaveCellInfo =true/false is working. I am no longer getting that exception.
I am sorry about the CurrentCellChanged event. It is CurrentCellAcceptedChanges that is getting invoked everytime I move from cell to cell. I want to do some calculations only when the user changes a value and leaves the cell. Currently I am using CurrentCellAcceptedChanges event. Everytime the user moves from cell to cell, my code is recalculating.
Is there any other event I can listen on that will tell me that some changes are made to the cell and the user is about to leave the cell?
ADAdministrator Syncfusion Team October 29, 2003 12:12 PM
You can try CurrentCellValidating. To get the new value, use grid.CurrentCell.Renderer.ControlText.