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
close icon

e.Cancel=true in ColsInserting does not stop insert

Hi, The problem we try to solve is this; Wy have a grind with a max number of cells. The number of rows restricts the number of columns and the other way around. To handle this we hook into the ColsInserting event and for each new row/column check whether the insert is ok. If not we set e.cancel=true. However, when we set the cancel flag we get: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: colIndex at Syncfusion.Collections.SFTable.set_Item(Int32 rowIndex, Int32 colIndex, Object value) at Syncfusion.Windows.Forms.Grid.GridRowCollection.set_Item(Int32 rowIndex, Int32 colIndex, GridStyleInfoStore value) at Syncfusion.Windows.Forms.Grid.GridData.set_Item(Int32 rowIndex, Int32 colIndex, GridStyleInfoStore value) at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly) System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: colIndex at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly) at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType) at Syncfusion.Windows.Forms.Grid.GridModel.ChangeCells(GridRangeInfo range, GridStyleInfo[] cellsInfo, StyleModifyType modifyType) at Syncfusion.Windows.Forms.Grid.GridModelStyleDataExchange.PasteCellsFromDataObject(GridData data, GridRangeInfo range, Boolean bIgnoreDiffRange, Int32 dragDropFlags) at Syncfusion.Windows.Forms.Grid.GridModelCutPaste.OnPasteFromClipboard(GridRangeInfo rg) at Syncfusion.Windows.Forms.Grid.GridModelCutPaste.Paste() at Syncfusion.Windows.Forms.Grid.GridControlBase.OnKeyDown(KeyEventArgs e) at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m) at Syncfusion.Windows.Forms.Grid.GridControlBase.ProcessKeyEventArgs(Message& m) at Syncfusion.Windows.Forms.Grid.GridControlBase.ProcessKeyPreview(Message& m) at System.Windows.Forms.Control.ProcessKeyPreview(Message& m) at Syncfusion.Windows.Forms.Grid.GridTextBoxControl.ProcessKeyMessage(Message& m) at System.Windows.Forms.Control.WmKeyChar(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.TextBoxBase.WndProc(Message& m) at System.Windows.Forms.RichTextBox.WndProc(Message& m) at Syncfusion.Windows.Forms.Grid.GridTextBoxControl.WndProc(Message& msg) catched at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly) in :line 0 catched at Syncfusion.Windows.Forms.Grid.GridTextBoxControl.WndProc(Message& msg) in :line 0 The cancel should stop the insert right?

7 Replies

AD Administrator Syncfusion Team June 1, 2006 04:45 AM UTC

Hi Fredrik, Canceling the cols/ rows insertion by setting the e.Cancel to true in the ColsInserting/ RowsInserting event handler works fine. I have attached a sample. Let me know if you are trying something different. Regards, Calvin.

Inserting_Cancel.zip


FS Fredrik Ström June 1, 2006 07:33 AM UTC

Thx for the reply, but i dont understand what your application should be doing. Please explain the settings and what should happen.


AD Administrator Syncfusion Team June 1, 2006 09:55 AM UTC

Hi Fredrick, The sample that I have sent shows that canceling the insertion of rows/cols by setting the e.Cancel to true in the RowsInserting/ ColsInserting event handler works fine. In the sample select “Cols”/ “Rows” from the listbox to insert columns/ rows respectively, and then select the position (At: ) where to insert, and the no. of rows/ cols (Count: ) to be inserted, and then press the Ok button. You will notice that the insertion will not take place when the Count is an odd number. private void gridControl1_ColsInserting(object sender, Syncfusion.Windows.Forms.Grid.GridRangeInsertingEventArgs e) { if(e.Count%2 != 0) e.Cancel = true; } private void gridControl1_RowsInserting(object sender, Syncfusion.Windows.Forms.Grid.GridRangeInsertingEventArgs e) { if(e.Count%2 != 0) e.Cancel = true; } Regards, Calvin.


FS Fredrik Ström June 1, 2006 10:13 AM UTC

Sadly enough i get the same exception with your example: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: colIndex at Syncfusion.Collections.SFTable.set_Item(Int32 rowIndex, Int32 colIndex, Object value) at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly) A first chance exception of type ''System.ArgumentOutOfRangeException'' occurred in Syncfusion.Grid.Windows.dll System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: colIndex at Syncfusion.Collections.SFTable.set_Item(Int32 rowIndex, Int32 colIndex, Object value) at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly) I happens when I paste and new columns are created to the right. The im using grind version 3.2.1.0


FS Fredrik Ström June 1, 2006 10:21 AM UTC

The simplest way to reproduce the error to: 1) enter 1 in row1,colA, "2" in row1,colB 2) copy the cells (ctrl-c) 3) paste the cells into row1,colJ 4 System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: colIndex at Syncfusion.Collections.SFTable.set_Item(Int32 rowIndex, Int32 colIndex, Object value) at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly) System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: colIndex at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly) at Syncfusion.Windows.Forms.Grid.GridModel.ChangeCells(GridRangeInfo range, GridStyleInfo[] cellsInfo, StyleModifyType modifyType) at Syncfusion.Windows.Forms.Grid.GridModelStyleDataExchange.PasteCellsFromDataObject(GridData data, GridRangeInfo range, Boolean bIgnoreDiffRange, Int32 dragDropFlags) at Syncfusion.Windows.Forms.Grid.GridModelCutPaste.OnPasteFromClipboard(GridRangeInfo rg) at Syncfusion.Windows.Forms.Grid.GridModelCutPaste.Paste() at Syncfusion.Windows.Forms.Grid.GridControlBase.OnKeyDown(KeyEventArgs e) at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m) at Syncfusion.Windows.Forms.Grid.GridControlBase.ProcessKeyEventArgs(Message& m) at Syncfusion.Windows.Forms.Grid.GridControlBase.ProcessKeyPreview(Message& m) at System.Windows.Forms.Control.ProcessKeyPreview(Message& m) at Syncfusion.Windows.Forms.Grid.GridTextBoxControl.ProcessKeyMessage(Message& m) at System.Windows.Forms.Control.WmKeyChar(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.TextBoxBase.WndProc(Message& m) at System.Windows.Forms.RichTextBox.WndProc(Message& m) at Syncfusion.Windows.Forms.Grid.GridTextBoxControl.WndProc(Message& msg) This exception is throw every time. So something happens even though e.cancel is set to true... Regards F


AD Administrator Syncfusion Team June 2, 2006 12:11 PM UTC

Hi Fredrik, The mentioned issue can be avoided by, also handling the ClipboardPaste event. And there check for the no. of columns/rows, and cancel the clipboard pasting accordingly. Modified sample attached. Regards, Calvin.

Inserting_Cancel0.zip


FS Fredrik Ström June 2, 2006 02:03 PM UTC

Thx, works like a charm :-D Regards F

Loader.
Live Chat Icon For mobile
Up arrow icon