Back to Devexpress

RichEditControl.EncryptDocumentFormShowing Event

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-71a808ab.md

latest4.9 KB
Original Source

RichEditControl.EncryptDocumentFormShowing Event

Occurs before the Encrypt Document Dialog is invoked.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public event EncryptDocumentFormShowingEventHandler EncryptDocumentFormShowing
vb
Public Event EncryptDocumentFormShowing As EncryptDocumentFormShowingEventHandler

Event Data

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

PropertyDescription
DialogResultGets or sets the return value of a dialog box. Inherited from ShowFormEventArgs.
EncryptionInfoProvides access to the encryption information.
HandledGets or sets whether an event was handled. If it was handled, the default actions are not required. Inherited from ShowFormEventArgs.
ParentGets or sets a parent of the form being shown. Inherited from ShowFormEventArgs.

Remarks

Handle the DocumentProtectionQueryNewPasswordFormShowing event to perform any actions prior to the Encrypt Document dialog being shown. You can substitute the standard dialog with a custom form and set the ShowFormEventArgs.Handled property to true to prevent default event handling.

The code sample below shows how to handle the EncryptDocumentFormShowing event to change the caption of the Encrypt Document dialog.

csharp
using DevExpress.XtraRichEdit.Forms;

class MyEncryptForm : EncryptDocumentForm
{
    public MyEncryptForm(IRichEditControl control, EncryptionInfo encryptionInfo) : base(control, encryptionInfo)
    {
        this.Text = "Password-Protect this Document";
    }
}
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.richEditControl1.EncryptDocumentFormShowing += RichEditControl1_EncryptDocumentFormShowing;
    }

    private void RichEditControl1_EncryptDocumentFormShowing(object sender, EncryptDocumentFormShowingEventArgs e)
    {
        MyEncryptForm frm = new MyEncryptForm(this.richEditControl1, e.EncryptionInfo);
        e.DialogResult = frm.ShowDialog();
        frm.Dispose();
        e.Handled = true;
    }
}
vb
Imports DevExpress.XtraRichEdit.Forms

Class MyEncryptForm
    Inherits EncryptDocumentForm

    Public Sub New(ByVal control As IRichEditControl, ByVal encryptionInfo As EncryptionInfo)
        MyBase.New(control, encryptionInfo)
        Me.Text = "Password-Protect this Document"
    End Sub
End Class

Public Partial Class Form1
    Inherits Form

    Public Sub New()
        InitializeComponent()
        Me.richEditControl1.EncryptDocumentFormShowing += AddressOf RichEditControl1_EncryptDocumentFormShowing
    End Sub

    Private Sub RichEditControl1_EncryptDocumentFormShowing(ByVal sender As Object, ByVal e As EncryptDocumentFormShowingEventArgs)
        Dim frm As MyEncryptForm = New MyEncryptForm(Me.richEditControl1, e.EncryptionInfo)
        e.DialogResult = frm.ShowDialog()
        frm.Dispose()
        e.Handled = True
    End Sub
End Class

See Also

How to: Customize the Hyperlink Form

How to: Customize the Find and Replace Dialog in Rich Text Editor for WinForms

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace