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[] { '' });
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.htmIssue 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