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.

copy multiple rows to insert ... DBG

Thread ID:

Created:

Updated:

Platform:

Replies:

89740 Sep 3,2009 04:57 PM Sep 7,2009 08:28 AM Windows Forms 3
loading
Tags: GridControl
David Cui
Asked On September 3, 2009 04:57 PM


hi,

I try to copy multiple (by highlight rows) to insert to the bottom of the Grid. Some how I got the following exception. Please advice .
Thanks. this for DataBoundGrid

David.

at System.Data.DataView.GetRow(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.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.EndUpdate()
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.GridModel.RaiseClipboardPaste(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 System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
at Syncfusion.Windows.Forms.Grid.GridControlBase.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg)
at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at OZCAP.CommonV2.UI.SQLToolBox.Program.Main() in C:\Development\SEG-Common-Code\DEV\OZCAP.CommonV2.Application\OZCAP.CommonV2.UI.SQLToolBox\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Rajadurai C [Syncfusion]
Replied On September 4, 2009 08:57 AM

Hi David,

Thanks for your interest in Syncfusion Products.

I was able to see the issue while copying a range of cells and pasting at the bottom of grid. It occurs when the pasting range is less than the copied range in grid. It is the default behavior in bounded grids. If you would like to avoid this exception, you can handle some condition check in ClipboardPaste event and paste accordingly.

Please refer to the following code handled in ClipboardPaste event.

void Model_ClipboardPaste(object sender, GridCutPasteEventArgs e)
{
int top1 = -1;
int left1 = -1;
int bottom1 = -1;
int right1 = -1;
foreach (GridRangeInfo range in e.RangeList)
{
top1 = range.Top;
left1 = range.Left;
bottom1 = range.Bottom;
right1 = range.Right;
break;
}
int row = bottom1 - top1 + 1;
int col = right1 - left1 + 1;
int row1 = this.gridDataBoundGrid1.Model.RowCount - this.gridDataBoundGrid1.CurrentCell.RowIndex;
int col1 = this.gridDataBoundGrid1.Model.ColCount - this.gridDataBoundGrid1.CurrentCell.ColIndex;
GridRangeInfoList list1 = new GridRangeInfoList();
if (row > row1)
{
while (row > row1 + 1)
{
bottom1 -= 1;
list1.Clear();
list1.Add(GridRangeInfo.Cells(top1, left1, bottom1, right1));
e.RangeList = list1;
row -= 1;
}
if (col > col1)
{
while (col > col1 + 1)
{
right1 -= 1;
list1.Clear();
list1.Add(GridRangeInfo.Cells(top1, left1, bottom1, right1));
e.RangeList = list1;
col -= 1;
}
}
GridData setdata = null;
int rowCount = 0;
int colCount = 0;
this.gridDataBoundGrid1.Model.DataExchange.CopyCellsToDataObject(out setdata, e.RangeList, true, GridDragDropFlags.Styles, out rowCount, out colCount);
DataObject data = new DataObject(setdata);
Clipboard.SetDataObject(data);
}
}

This checks for the range of pasting range and copied range. If the paste range is less than the copied range, it cancels the pasting. Else, it copies as normal. This avoid throwing exception.

Sample:
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/F89740.zip

Regards,
Rajadurai

David Cui
Replied On September 4, 2009 10:01 AM



Rajadurai,

I commented out this.gridDataBoundGrid1.UseRightToLeftCompatibleTextBox = true , then i be able to compile the sample.

It works. The exception disapears.

Only thing is how can I paste multiple rows to the end ? I am using Syncfusion 4.2 .

best regards,

David

Rajadurai C [Syncfusion]
Replied On September 7, 2009 08:28 AM

Hi David,

By default, the cells can be copied to clipboard and pasted in grid. As the griddataboundgrid is bounded one, pasting of large range in range of cells such that there are no more rows in grid to accomodate it, raises exception. The code which i provided in the ClipboardPaste event in previous update along with sample check for this and allow pasting only when there is enough area in grid to accomodate the copied cell contents. The additional rows cannot be added with this grid as this may lead to entry of unnecessary records in binded datasoure.

Please let me know if you have any further concerns.

Regards,
Rajadurai

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.

;