GridControl.ClipboardRowCopying Event
Occurs before the GridControl copies data to the clipboard and allows you to process the copy operation.
Namespace: DevExpress.WinUI.Grid
Assembly: DevExpress.WinUI.Grid.v23.2.dll
NuGet Package: DevExpress.WinUI
#Declaration
public event ClipboardRowCopyingEventHandler ClipboardRowCopying
#Event Data
The ClipboardRowCopying event's data class is ClipboardRowCopyingEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets whether to exclude the processed grid element from the copy operation’s result. |
Row |
Gets the processed row’s handle (Invalid |
Type | Gets the type of the copied element: column headers, group rows, or data rows. |
Values | Gets information about the copied grid element (a column headers collection, group row, or data row) with its appearance settings. |
#Remarks
The GridControl raises the ClipboardRowCopying event for each copied row. The event considers the column header row as the first copied row if the CopyColumnHeadersToClipboard property is set to true.
This event allows you to modify the copy operation. For example, you can change copied values, skip a row, or customize row appearance.
The following code sample adds group summaries to the copied group rows and changes the background of group rows:
<dxg:GridControl ...
x:Name="grid"
CopyColumnHeadersToClipboard="True"
ClipboardRowCopying="grid_ClipboardRowCopying">
<dxg:GridControl.GroupSummary>
<dxg:GridGroupSummaryItem x:Name="groupSummary" FieldName="UnitPrice" SummaryType="Max"/>
</dxg:GridControl.GroupSummary>
<!-- ... -->
</dxg:GridControl>
using Microsoft.UI;
using Microsoft.UI.Xaml.Media;
// ...
void grid_ClipboardRowCopying(object sender, DevExpress.WinUI.Grid.ClipboardRowCopyingEventArgs e) {
if (e.Type == ClipboardInfoType.Group) {
var group = e.Values[0];
group.Value = group.DisplayValue + $" (Max of Unit Price is ${grid.GetGroupSummaryValue(e.RowHandle, groupSummary)})";
group.Background = new SolidColorBrush(Colors.LightGray);
}
}