TreeList.ClipboardNodeCopying 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.XtraTreeList
Assembly: DevExpress.XtraTreeList.v19.2.dll
Declaration
Event Data
The ClipboardNodeCopying event's data class is ClipboardNodeCopyingEventArgs. The following properties provide information specific to this event:
Property |
---|
Cancel |
Headers |
Type |
Values |
Remarks
If the TreeList.OptionsClipboard.ClipboardMode option is set to Formatted, the ClipboardNodeCopying event fires before a node, column headers, or band headers are copied to the clipboard. The event allows you to apply a format, change the copied data, or skip a data row or header.
Note
Run the XtraTreeList demo to see how to copy and paste data.
Row Type
The Type event argument returns the processed row type:
- Row — a tree list node.
- ColumnHeader — column headers (headers are copied if the TreeList.OptionsClipboard.CopyColumnHeaders option is enabled).
- BandHeader — band headers.
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 tree list nodes.
- 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 names. The returned object contains view information about the cell. You can specify the following properties:
- Column — gets a TreeListColumn or TreeListBand object that specifies the processed column or band.
- 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.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
private void TreeList1_ClipboardNodeCopying(object sender, ClipboardNodeCopyingEventArgs e) {
switch (e.Type) {
case ClipboardInfoType.ColumnHeader:
var salesHeaderInfo = e.Headers[colRegion];
var salesHeaderInfo1 = e.Headers["Region"];
if (salesHeaderInfo != null) {
salesHeaderInfo.BackColor = Color.Red;
salesHeaderInfo.ForeColor = Color.White;
salesHeaderInfo.BorderLeft = new ClipboardCellBorderInfo(Color.BlanchedAlmond, DevExpress.XtraExport.Helpers.BorderStyle.DashDotDot);
salesHeaderInfo.BorderTop = new ClipboardCellBorderInfo(Color.Crimson, DevExpress.XtraExport.Helpers.BorderStyle.DashDotDot);
salesHeaderInfo.BorderRight = new ClipboardCellBorderInfo(Color.CornflowerBlue, DevExpress.XtraExport.Helpers.BorderStyle.Dotted);
salesHeaderInfo.BorderBottom = new ClipboardCellBorderInfo(Color.Red, DevExpress.XtraExport.Helpers.BorderStyle.DashDot);
salesHeaderInfo.Value = "REGION";
}
break;
case ClipboardInfoType.BandHeader:
// The code does not copy band headers.
e.Cancel = true;
//var salesBandHeaderInfo = e.Headers[treeListBand1];
//var salesBandHeaderInfo1 = e.Headers["treeListBand1"];
break;
case ClipboardInfoType.Row:
//var regionCellInfo = e.Values[colRegion];
var regionCellInfo1 = e.Values["Region"];
if (regionCellInfo1.Value.Equals("France"))
e.Cancel = true;
break;
}
}