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 stop the errors thrown when pasting larger clipboard contents in a GridDataBoundGrid?

Platform: WinForms |
Control: GridDataBoundGrid(Classic) |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

A IndexOutOfRangeException is thrown when trying to paste clipboard contents that are greater than the number of columns and rows that are available to accommodate the contents. To stop the exception, a condition check in the Model.PasteCellText handler will do good.

C#

private void Model_PasteCellText(object sender, Syncfusion.Windows.Forms.Grid.GridPasteCellTextEventArgs e)

{

if(e.RowIndex >= this.gridDataBoundGrid1.Model.RowCount)

{

MessageBox.Show("There is no enough rows to paste the rest of the contents");

e.Cancel = true;

e.Abort = true;

}

}

VB

Private Sub Model_PasteCellText(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPasteCellTextEventArgs)

If e.RowIndex >= Me.gridDataBoundGrid1.Model.RowCount Then

MessageBox.Show("There is no enough rows to paste the rest of the contents")

e.Cancel = True

e.Abort = True

End If

End Sub

Here is a sample that illustrates this:

http://websamples.syncfusion.com/samples/KB/Grid.Windows/AvoidingPasteError/main.htm

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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