corelibraries-devexpress-dot-data-dot-utils-dot-clipboardaccesspolicy-35845711.md
Fires when the user attempts to copy data displayed in a DevExpress control to the clipboard and allows you to allow (or cancel) the operation.
Namespace : DevExpress.Data.Utils
Assembly : DevExpress.Data.Desktop.v25.2.dll
NuGet Packages : DevExpress.Data.Desktop, DevExpress.ExpressApp.Win.Design
public static event EventHandler<ClipboardAccessPolicy.ClipboardOperationRequestEventArgs> Copying
Public Shared Event Copying As EventHandler(Of ClipboardAccessPolicy.ClipboardOperationRequestEventArgs)
The Copying event's data class is ClipboardAccessPolicy.ClipboardOperationRequestEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
| DataFormat | Gets the data format. |
| DataObject | Gets an object that defines a format-independent mechanism for transferring data. |
| IsClearOperation | Gets a value that indicates whether the clipboard clear operation is being processed. |
| IsCopyOperation | Gets a value that indicates whether the copy-to-clipboard operation is being processed. |
| IsDataObjectRequested | |
| IsPasteOperation | Gets a value that indicates whether the paste-from-clipboard operation is being processed. |
| IsUIStateQuery | Gets a value that indicates whether a DevExpress UI control requests a copy/paste operation to update its UI (for example, menu commands). |
| Operation | Gets the clipboard-related operation being processed. |
The event data class exposes the following methods:
| Method | Description |
|---|---|
| ToString() | Returns a string representation of the current object. |
The Clipboard Access Policy fires the Copying event when a user attempts to copy data displayed in a DevExpress UI control to the clipboard and allows you to allow (or cancel) the operation based on a specific condition. If you disabled copy-to-clipboard operations, set the e.Cancel parameter to false to allow the operation.
The following example demonstrates how to allow users to copy data in ANSI text format displayed in a DevExpress UI control to the clipboard. If the control displays data in a different format, the copy-to-clipboard operation is canceled:
using System;
using System.Windows.Forms;
using DevExpress.Data.Utils;
namespace DXApplication {
internal static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ClipboardAccessPolicy.SuppressCopyOperations();
ClipboardAccessPolicy.Copying += ClipboardAccessPolicy_Copying;
Application.Run(new Form1());
}
private static void ClipboardAccessPolicy_Copying(object sender, ClipboardAccessPolicy.ClipboardOperationRequestEventArgs e) {
if (e.DataFormat == DataFormats.Text)
e.Cancel = false;
}
}
}
Imports System
Imports System.Windows.Forms
Imports DevExpress.Data.Utils
Namespace DXApplication
Friend Module Program
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread>
Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
ClipboardAccessPolicy.SuppressCopyOperations()
AddHandler ClipboardAccessPolicy.Copying, AddressOf ClipboardAccessPolicy_Copying
Application.Run(New Form1())
End Sub
Private Sub ClipboardAccessPolicy_Copying(ByVal sender As Object, ByVal e As ClipboardAccessPolicy.ClipboardOperationRequestEventArgs)
If e.DataFormat = DataFormats.Text Then
e.Cancel = False
End If
End Sub
End Module
End Namespace
Read the following topic for additional information: Clipboard Access Policy.
See Also