Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Interrupt Paste of multiple rows into UltraGrid

Hi All,

I am using an UltraWinGrid in version 18.1 and would like to interrupt the paste of multiple rows into the grid. 

There are 2 scenarios that I would like to overcome, both should result in the early interrupt of the process (ie, remaining rows not added to the UltraGrid). 

There are times when a user will paste between 500-1000 rows from Excel to a Grid, and if an issue is identified should be interrupted.

1. On a validation error (eg due to data type inconsistencies, pasting int into datetime) allow the user to have a Cancel button rather than just an OK. 
Currently there is a validation error for every row, and the user must either click 'OK' or hold the 'Escape' key to quickly close the message. 

2. Incorrect Data pasted. eg Columns in the wrong order, but datatype is acceptable.  FirstName,LastName compared to LastName,FirstName
During the paste of this there is no validation message, but depending on the UltraGrid this can take a significant amount of time to have to wait and then remove the pasted rows. 

I thought about hooking into the BeforeNewRowEvent on the UltraGrid, but have not identified how to pass a break signal into it. And subsequently, if it is possible to interrupt the whole paste action, or just cancel the creation of new rows.

 public static void BeforeNewRowEvent(object sender, System.ComponentModel.CancelEventArgs e) {
            if (IsEscapeKeyDown()) {
                e.Cancel = true;

Please let me know if you need any info.

  • 26425
    Offline posted


    Note, BeforeNewRow event is not an UltraGrid event.

    You can stop a paste operate from happening as soon as the first error occurs by handling the grid's Error event, checking if the ErrorType is MultiCellOperation and cancel the event. 

    private void UltraGrid1_Error(object sender, Infragistics.Win.UltraWinGrid.ErrorEventArgs e)
                if (e.ErrorType == Infragistics.Win.UltraWinGrid.ErrorType.MultiCellOperation)
                    e.Cancel = true;