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