Skip to main content
A newer version of this page is available. .

GridView.ClipboardRowPasting Event

Repeatedly fires for each pasted row before updating the control, and allows you to modify pasted data and to cancel the pasting of the currently processed row.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v19.2.dll

Declaration

[DXCategory("Action")]
public event ClipboardRowPastingEventHandler ClipboardRowPasting

Event Data

The ClipboardRowPasting event's data class is ClipboardRowPastingEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets whether the current operation should be canceled.
DataRowCount Gets the total count of data rows to process.
OriginalValues Returns a read-only collection of individual pasted values.
PasteMode Gets or sets whether only valid rows or all rows are pasted to the control.
RowCount Gets the total count of rows to process.
RowHandle Returns the unique identifier (handle) of the currently processed row.
Values Returns a dictionary that contains “target column - pasted value” pairs. You can modify pasted values in this dictionary to perform custom pasting.

The event data class exposes the following methods:

Method Description
GetInvalidValues() Returns a dictionary that contains invalid column-value pairs. Invalid pairs identify values that cannot be accepted by corresponding columns.
GetValidValues() Returns a dictionary that contains valid column-value pairs. Valid pairs identify values that can be accepted by corresponding columns.
IsRowValid() Returns whether pasted values can be accepted by target columns. Both the pasted values and target columns are specified by the ClipboardRowPastingEventArgs.Values dictionary.
IsValueValid(GridColumn, Object, out Exception) Returns whether the specified value can be pasted to the specified column cell.
IsValueValid(String, Object, out Exception) Returns whether the specified value can be pasted to the column with the specified field name.

Remarks

If pasted data contains multiple rows, the ClipboardRowPasting event fires for each of these rows. It fires before data in the target control is updated and allows you to modify the pasted data and to cancel the pasting of certain rows.

Use the ClipboardRowPastingEventArgs.Values event parameter to access and modify pasted values.

By default, if any value in the pasted row does not match its target column (e.g., the value’s data type cannot be converted to the column’s data type), this row is considered invalid and this row pasting is canceled. The value and row validity can be performed with the ClipboardRowPastingEventArgs.IsValueValid and ClipboardRowPastingEventArgs.IsRowValid methods. To force invalid row pasting, you can set the ClipboardRowPastingEventArgs.PasteMode event parameter to Force.

Set the Cancel parameter to true to skip the current row during data pasting.

See Clipboard - Copy and Paste Operations. Data Formatting to learn more.

See Also