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.
Unfortunately, activation email could not send to your email. Please try again.

DataBoundGrid throwing exception when pasting values

Thread ID:

Created:

Updated:

Platform:

Replies:

8561 Nov 11,2003 05:47 PM Nov 12,2003 02:05 AM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 11, 2003 05:47 PM

Hi, I am using 1.6.1.8 Data bound grid. When I try to copy/paste rows into my grid, it throws some exception from grid base classes. You can reproduce this error in the FilterBarGrid sample. 1. Run 2 instances of the sample. 2. Highlight 3 or 4 rows (or some area with 3 cols/4 rows) and click Ctrl-C 3. Goto the second instance (which is executing from VS.NET, click in the last row (add new row) and hit Ctrl-V. 4. Notice the following exception in the output window. Can you please look into this. Thanks, - Reddy Additional information: Object reference not set to an instance of an object. Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.System.IndexOutOfRangeException: Index 91 is not non-negative and below total rows count. at System.Data.DataView.GetElement(Int32 index) at System.Data.DataView.System.Collections.IList.get_Item(Int32 recordIndex) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.SaveCellInfo(GridSaveCellInfoEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.Syncfusion.Windows.Forms.Grid.IGridModelDataProvider.SaveCellInfo(GridSaveCellInfoEventArgs e) 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.GridModel.Syncfusion.Windows.Forms.Grid.IGridVolatileDataContainer.ChangeCell(Int32 rowIndex, Int32 colIndex, GridStyleInfo style) at Syncfusion.Windows.Forms.Grid.GridVolatileData.set_Item(Int32 rowIndex, Int32 colIndex, GridStyleInfo value) at Syncfusion.Windows.Forms.Grid.GridStyleInfoIdentity.OnStyleChanged(StyleInfoBase style, StyleInfoProperty sip) at Syncfusion.Styles.StyleInfoBase.OnStyleChanged(StyleInfoProperty sip) at Syncfusion.Windows.Forms.Grid.GridStyleInfo.OnStyleChanged(StyleInfoProperty sip) at Syncfusion.Styles.StyleInfoBase.SetValue(StyleInfoProperty sip, Object value) at Syncfusion.Windows.Forms.Grid.GridStyleInfo.set_CellValue(Object value) at Syncfusion.Windows.Forms.Grid.GridCellModelBase.ApplyFormattedText(GridStyleInfo style, String text, Int32 textInfo) at Syncfusion.Windows.Forms.Grid.GridStyleInfo.ApplyFormattedText(String text, Int32 textInfo) at Syncfusion.Windows.Forms.Grid.GridModelTextDataExchange.PasteTextRowCol(Int32 rowIndex, Int32 colIndex, String text) at Syncfusion.Windows.Forms.Grid.GridModelDataBinder.DataBoundPaste(IDataObject iData, Int32 clipboardFlags, GridRangeInfoList rangeList, GridCutPasteEventArgs e) at Syncfusion.Windows.Forms.Grid.GridDataBoundGridModel.OnClipboardPaste(GridCutPasteEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelCutPaste.Paste() at Syncfusion.Windows.Forms.Grid.GridControlBase.OnKeyDown(KeyEventArgs e) at Syncfusion.Windows.Forms.Grid.GridDataBoundGrid.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.ProcessKeyMessage(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.GridTextBoxControl.WndProc(Message& msg) in :line 0

Administrator [Syncfusion]
Replied On November 12, 2003 02:05 AM

If you just want to avoid the error, you can subscribe to PasteCellText and cancel the paste if you are trying to paste beyond the populated grid. //subscribe to the event this.gridDataBoundGrid1.Model.PasteCellText += new GridPasteCellTextEventHandler(grid_PasteCellText); //the handler //the handler private void grid_PasteCellText(object sender, GridPasteCellTextEventArgs e) { if(e.RowIndex >= this.gridDataBoundGrid1.Model.RowCount) { e.Cancel = true; } } This avoids the complexity to trying to add rows to your datasource and pasteing over unique foreign keys, etc. But if you want to auto-append new rows, you can do so in Model.ClipboardPaste. Attached is a little sample. Exactly how you might do it, depends upon your datasource and how you want to avoid unique foreign keys trying to be pasted over. The little sampple does not have foreign keys...

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.

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.

;