Back to Devexpress

ClipboardAccessPolicy.FailedEventArgs.Throw Property

corelibraries-devexpress-dot-data-dot-utils-dot-clipboardaccesspolicy-dot-failedeventargs-4de1150e.md

latest3.4 KB
Original Source

ClipboardAccessPolicy.FailedEventArgs.Throw Property

Gets or sets whether to throw an exception.

Namespace : DevExpress.Data.Utils

Assembly : DevExpress.Data.Desktop.v25.2.dll

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

Declaration

csharp
public bool Throw { get; set; }
vb
Public Property [Throw] As Boolean

Property Value

TypeDescription
Boolean

true to throw an exception; otherwise, false.

|

Remarks

The following example demonstrates how to suppress an internal exception and display a message box:

csharp
using System;
using System.Windows.Forms;
using DevExpress.Data.Utils;
using DevExpress.XtraEditors;

namespace DXApplication11 {
    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) {
            e.Throw = false;
            XtraMessageBox.Show(String.Format("{0} operation is not allowed.", e.Operation.ToString()), "Warning");
        }
    }
}
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.Data.Utils
Imports DevExpress.XtraEditors

Namespace DXApplication11
    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)
            e.Throw = False
            XtraMessageBox.Show(String.Format("{0} operation is not allowed.", e.Operation.ToString()), "Warning")
        End Sub
    End Module
End Namespace

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

See Also

ClipboardAccessPolicy.FailedEventArgs Class

ClipboardAccessPolicy.FailedEventArgs Members

DevExpress.Data.Utils Namespace