I have the following line of code in the AfterPaste event of a grid control
moGrid(moGrid.CurrentCell.RowIndex, GridCol.Installed).Text = False
However, this line trips a "Grid is in updating mode" error. I''ve tried CancelUpdate and CancelEdit before that line, but to no avail.
Anyone know a) why this error occurs and b) how I can prevent it?
ADAdministrator Syncfusion Team July 28, 2005 03:22 PM
I am not sure what the AfterPaste event is? Can you post the code that you use to subscribe to this event? Is it an event you added?
SSSteve SmithJuly 28, 2005 05:41 PM
Sorry, this was code I inherited and I (wrongly) assummed the AfterPaste event was Syncfusions. Anyway, here''s how the code looks (the error is tripped by the first line in AfterPaste:
Public WithEvents moGrid As Syncfusion.Windows.Forms.Grid.GridControl
Private Sub moGrid_ClipboardPaste(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCutPasteEventArgs) Handles moGrid.ClipboardPaste
tmr.Interval = 200 ''give the paste enough time to complete, then fire the update
Private Sub tmr_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles tmr.Elapsed
Private Sub AfterPaste()
moGrid(moGrid.CurrentCell.RowIndex, GridCol.Installed).Text = False '' THIS IS THE OFFENDING LINE!!
If moGrid(moGrid.CurrentCell.RowIndex, GridCol.LineType).Text = CEnumsInfo.LineTypes.Comment.ToString Then
moGrid(moGrid.CurrentCell.RowIndex, -1).Font.Bold = True
moGrid(moGrid.CurrentCell.RowIndex, -1).Font.Bold = False
If moGrid(moGrid.CurrentCell.RowIndex, GridCol.LineType).Text = CEnumsInfo.LineTypes.SubAsy.ToString Then
moGrid(moGrid.CurrentCell.RowIndex, GridCol.SubAssembly).Text = "+"
If moGrid.CurrentCell.RowIndex = moGrid.RowCount Then
moGrid.RowCount += 1
>I am not sure what the AfterPaste event is? Can you post the code that you use to subscribe to this event? Is it an event you added?
ADAdministrator Syncfusion Team July 28, 2005 06:28 PM
Are you using multiple threads? If so, and you are not using grid.InvodekRequired checked before accessing grid methods, you can see exceptions like this.
But if you are not using multiple threads, then it might be that the 200 ms is not long enough for the paste to complete. You caold lengthen this time to see if this is the problem.