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.

How to abort pasting in GDBG?

Thread ID:

Created:

Updated:

Platform:

Replies:

67749 Aug 29,2007 10:56 AM Sep 1,2007 05:01 AM Windows Forms 2
loading
Tags: GridControl
Valerij
Asked On August 29, 2007 10:56 AM

Hello,

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.

Valerij
Replied On August 30, 2007 02:59 AM

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?

gridPaste_bug.zip

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

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:
http://websamples.syncfusion.com/samples/Grid.Windows/F67749/main.htm

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,
Golda

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.

;