Back to Devexpress

GridControl.CopyingToClipboard Event

wpf-devexpress-dot-xpf-dot-grid-dot-gridcontrol-a9937e4b.md

latest7.1 KB
Original Source

GridControl.CopyingToClipboard Event

Occurs when grid data is copied to the clipboard. It allows you to manually copy required data.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event CopyingToClipboardEventHandler CopyingToClipboard
vb
Public Event CopyingToClipboard As CopyingToClipboardEventHandler

Event Data

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

PropertyDescription
CopyHeaderGets whether column headers are copied to the clipboard. Inherited from CopyingToClipboardEventArgsBase.
GridCellsGets an array of cells whose values are about to be copied to the clipboard.
HandledGets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
OriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
RowHandlesGets an array of handles that correspond to rows whose values are to be copied to the clipboard. Inherited from CopyingToClipboardEventArgsBase.
SourceGets the View that raised the event. Inherited from CopyingToClipboardEventArgsBase.

The event data class exposes the following methods:

MethodDescription
InvokeEventHandler(Delegate, Object)When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs.
OnSetSource(Object)When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs.

Remarks

The GridControl provides the GridControl.CopyingToClipboard event that allows you to process copy operations manually. This event is raised before row values are copied to the clipboard by an end user or in code.

The following code sample demonstrates how to process data that is copied to the clipboard:

xaml
<dxg:GridControl CopyingToClipboard="OnCopyingToClipboard" />
csharp
void OnCopyingToClipboard(object sender, CopyingToClipboardEventArgs e) {
    Clipboard.Clear();
    // You should manually implement the GetRowData() method 
    // that returns data to be copied to the clipboard.
    Clipboard.SetData(DataFormats.Text, GetRowData());
    e.Handled = true;
}
vb
Private Sub OnCopyingToClipboard(ByVal sender As Object, ByVal e As CopyingToClipboardEventArgs)
    Clipboard.Clear()
    ' You should manually implement the GetRowData() method 
    ' that returns data to be copied to the clipboard.
    Clipboard.SetData(DataFormats.Text, GetRowData())
    e.Handled = True
End Sub

Note

Tip

Views provide two events that allow you to manually process clipboard operations.

See Also

Copy Operations

GridControl Class

GridControl Members

DevExpress.Xpf.Grid Namespace