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

How to abort pasting in GDBG?

Thread ID:





67749 Aug 29,2007 02:56 PM UTC Sep 1,2007 09:01 AM UTC WinForms 2
Tags: GridControl
Asked On August 29, 2007 02:56 PM UTC


how can I abort clipboard pasting if content is bigger than GridDataBoundGrid row and column count?

Currently, I am using Model.PasteCellText event from next example: http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=327. Manual (http://www2.syncfusion.com/cref/Default.aspx##Class%20Reference.chm//E_Syncfusion_Windows_Forms_Grid_GridModel_PasteCellText.html) says that "e.Abort = true" abort current operation, but actually it does not rollback any changes, just stop the paste operation.

Replied On August 30, 2007 06:59 AM UTC

Here is little example.

0) Open&Run attached example
1) Select first 5 rows
2) Press ctrl + c
3) Move cursor to the next row (row "6")
4) Press ctrl + v

Error message appears, but rows 6-8 contains new values. How can I abort (rollback) pasting operation at all in case of error?

There also is strange difference in grid behaviour:

1) Open my example
2) Comment next line:
gridDataBoundGrid1.Model.PasteCellText += new Syncfusion.Windows.Forms.Grid.GridPasteCellTextEventHandler(Model_PasteCellText);
3) Run example
4) Select first 5 rows
5) Press ctrl + c
6) Move cursor to the next row (row "6")
7) Press ctrl + v

Ok. Now restart application

1) Select first 5 rows
2) Press ctrl + c
3) Now select rows from 6 to 8
4) Press ctrl + v

Exception is trown.

Why in first case exception is NOT thrown and in second case exception is thrown?


Golda Rebecal [Syncfusion]
Replied On September 1, 2007 09:01 AM UTC

Hi Valerij,

Issue 1:

You can use ClipBoardPaste event to cancel pasting if the content to be pasted exceeds the grid row count.

void Model_ClipboardPaste(object sender, Syncfusion.Windows.Forms.Grid.GridCutPasteEventArgs e)
DataObject data = (DataObject)Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Text))
ArrayList arr = new ArrayList();
string s = (string)data.GetData(DataFormats.Text);
string[] rows = s.Split(new char[] { '\n' });
int numRows = rows.GetLength(0);
if (numRows > 0 && rows[numRows - 1].Length == 0)
numRows--; //remove extra empty row if present

int rem = this.gridDataBoundGrid1.Model.RowCount - numRows;
if (rem < numRows)
e.Handled = true;
e.Result = true;

Please refer to the attached sample that illustrates the same:

Issue 2:
Exceptions occur in both the cases. In the first case, since the 6th row is in edit mode, EndEdit event is handled and then the ClipBoardPaste event is handled. In this case, you could see the exception message in the output window.

In the second case, since a range of rows is selected, ClipBoardPaste event is directly handled and exception is thrown explicitly.

Kindly let me know if you need any further assistance.

Best regards,


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