corelibraries-devexpress-dot-data-dot-utils-dot-clipboardaccesspolicy-8a332a70.md
Allows you to respond to associated failures.
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.FailedEventArgs> Failed
Public Shared Event Failed As EventHandler(Of ClipboardAccessPolicy.FailedEventArgs)
The Failed event's data class is ClipboardAccessPolicy.FailedEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| DataFormat | Gets the data format. Inherited from ClipboardAccessPolicy.ClipboardOperationEventArgs. |
| DataObject | Gets an object that defines a format-independent mechanism for transferring data. Inherited from ClipboardAccessPolicy.ClipboardOperationEventArgs. |
| Exception | Gets the exception. |
| IsClearOperation | Gets a value that indicates whether the clipboard clear operation is being processed. Inherited from ClipboardAccessPolicy.ClipboardOperationEventArgs. |
| IsCopyOperation | Gets a value that indicates whether the copy-to-clipboard operation is being processed. Inherited from ClipboardAccessPolicy.ClipboardOperationEventArgs. |
| IsPasteOperation | Gets a value that indicates whether the paste-from-clipboard operation is being processed. Inherited from ClipboardAccessPolicy.ClipboardOperationEventArgs. |
| Operation | Gets the clipboard-related operation being processed. Inherited from ClipboardAccessPolicy.ClipboardOperationEventArgs. |
| Throw | Gets or sets whether to throw an exception. |
The event data class exposes the following methods:
| Method | Description |
|---|---|
| ToString() | Returns a string representation of the current object. |
The ThrowAlways() method disables all clipboard-related operations (copy, paste, clear) in DevExpress WinForms and WPF controls. The Clipboard Access Policy throws an exception when a user or UI control attempts to perform an operation with the clipboard.
Handle the Failed event to respond to associated failures:
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.ThrowAlways();
ClipboardAccessPolicy.Failed += ClipboardAccessPolicy_Failed;
Application.Run(new Form1());
}
private static void ClipboardAccessPolicy_Failed(object sender, ClipboardAccessPolicy.FailedEventArgs e) {
if (e.DataFormat == DataFormats.Text)
e.Throw = 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.ThrowAlways()
AddHandler ClipboardAccessPolicy.Failed, AddressOf ClipboardAccessPolicy_Failed
Application.Run(New Form1())
End Sub
Private Sub ClipboardAccessPolicy_Failed(ByVal sender As Object, ByVal e As ClipboardAccessPolicy.FailedEventArgs)
If e.DataFormat = DataFormats.Text Then
e.Throw = False
End If
End Sub
End Module
End Namespace
Read the following topic for additional information: Clipboard Access Policy.
See Also