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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Exception pasting rows

Thread ID:





28066 Apr 22,2005 03:52 PM UTC Apr 22,2005 05:15 PM UTC WinForms 1
Tags: GridControl
Raul Rosenthal
Asked On April 22, 2005 03:52 PM UTC

I have a data bound grid. I use GridModelCutPaste.Paste to paste a row I just copied. I set EnableAddNew to true. If I try to paste to the last row (the fake one used to add record), I get an exception. If I paste to a real row, it works fine. Here''s the stack trace: Object reference not set to an instance of an object. 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.GridComboBoxCellModel.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.GridModel.RaiseClipboardPaste(GridCutPasteEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelCutPaste.Paste() at SDB.viewRule.HandleCommand(String cmd, Object arg) at SDB.cmdDispatcher.DispatchCommand(String cmd, Object arg)

Administrator [Syncfusion]
Replied On April 22, 2005 05:15 PM UTC

If you want to append rows dusing a paste, you will have to handle this your self. One way is to subscribe to the PasteCellText and add the row there is needed.
//subscribe to the event
this.gridDataBoundGrid1.Model.PasteCellText += new GridPasteCellTextEventHandler(Model_PasteCellText);

//the handler
private void Model_PasteCellText(object sender, GridPasteCellTextEventArgs e)
	if(e.ColIndex > this.gridDataBoundGrid1.Model.ColCount)
		e.Cancel = true;
	else if(e.RowIndex == this.gridDataBoundGrid1.Model.RowCount)
		CurrencyManager cm = this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource, 
			                                    this.gridDataBoundGrid1.DataMember] as CurrencyManager;
	else if(e.RowIndex >= this.gridDataBoundGrid1.Model.RowCount)
		e.Cancel = true;


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon