All docs
V19.2
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
A newer version of this page is available. Switch to the current version.

GridView.ClipboardRowCopying Event

Fires before a data row, group row, column headers, or band headers are copied to the clipboard. Allows you to apply a format, change the copied data, or skip a data row or header.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v19.2.dll

Declaration

[DXCategory("Action")]
public event ClipboardRowCopyingEventHandler ClipboardRowCopying
<DXCategory("Action")>
Public Event ClipboardRowCopying As ClipboardRowCopyingEventHandler

Event Data

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

Property
Cancel
Headers
Type
Values

Remarks

If the GridView.OptionsClipboard.ClipboardMode option is set to Formatted, the ClipboardRowCopying event fires before a data row, group row, group summary, column headers, or band headers are copied to the clipboard. The event allows you to change the copied value, customize the cell appearance, or skip certain rows.

NOTE

Run the XtraGrid demo to see how to copy and paste data.

Row Types

The Type event argument returns the processed row type:

  • Row — a data row.
  • ColumnHeader — column headers (headers are copied if the GridView.OptionsClipboard.CopyColumnHeaders option is enabled).
  • BandHeader — band headers.
  • Group — a group row.
  • GroupSummary — group summaries.

To prevent the processed row from being copied, set the Cancel event argument to true.

Cells

Depending on the row type, use the following collections to access the processed cells:

  • Values — provides access to a collection of cells in data rows, group rows and group summaries.
  • Headers — provides access to a collection of cells in column headers and band headers.

You can index cells by column/band objects or by field names/band captions. The returned object contains view information about the cell. You can specify the following properties:

  • Column — gets a GridColumn, GridBand, or BandedGridColumn object that specifies the processed column.
  • BackColor, ForeColor — get or set the background and foreground colors for the cell.
  • Font - gets or sets the font of the text displayed in the cell.
  • BorderBottom, BorderLeft, BorderRight, BorderTop — get or set BorderInfo structures that specify the corresponding border's color and style (dash, dot, etc.).
  • Value — gets or sets an object that specifies the cell's value.

Example

The code below shows how to change a column header's caption and appearance.

using DevExpress.XtraExport.Helpers;
using DevExpress.XtraGrid.Views.Grid;

private void gridView1_ClipboardRowCopying(object sender, ClipboardRowCopyingEventArgs e) {
    switch (e.Type) {
        case ClipboardInfoType.ColumnHeader:
            var columnHead = e.Headers[colSales];
            //var columnHead1 = e.Headers["Sales"];
            columnHead.BackColor = Color.Red;
            columnHead.ForeColor = Color.White;
            columnHead.Value = "SALES";
            columnHead.BorderLeft = new ClipboardCellBorderInfo(Color.BlanchedAlmond, DevExpress.XtraExport.Helpers.BorderStyle.DashDotDot);
            columnHead.BorderTop = new ClipboardCellBorderInfo(Color.Crimson, DevExpress.XtraExport.Helpers.BorderStyle.DashDotDot);
            columnHead.BorderRight = new ClipboardCellBorderInfo(Color.CornflowerBlue, DevExpress.XtraExport.Helpers.BorderStyle.Dotted);
            columnHead.BorderBottom = new ClipboardCellBorderInfo(Color.Red, DevExpress.XtraExport.Helpers.BorderStyle.DashDot);
            break;
        case ClipboardInfoType.Group:
            e.Cancel = true;
            break;
        case ClipboardInfoType.Row:
            //var regionCellInfo = e.Values[colState];
            var regionCellInfo1 = e.Values["State"];
            if (regionCellInfo1.Value.Equals("California"))
                e.Cancel = true;
            break;
    }
}
See Also