Skip to main content
All docs
V24.1

ClipboardAccessPolicy.Failed Event

Allows you to respond to associated failures.

Namespace: DevExpress.Data.Utils

Assembly: DevExpress.Data.Desktop.v24.1.dll

NuGet Packages: DevExpress.Data.Desktop, DevExpress.ExpressApp.Win.Design

Declaration

public static event EventHandler<ClipboardAccessPolicy.FailedEventArgs> Failed

Event Data

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.

Remarks

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;
        }
    }
}

Read the following topic for additional information: Clipboard Access Policy.

See Also