RichEditControl.EncryptedFilePasswordRequested Event
Occurs when the EncryptionPassword property is not set or returns an invalid password.
Namespace: DevExpress.Xpf.RichEdit
Assembly: DevExpress.Xpf.RichEdit.v24.2.dll
NuGet Package: DevExpress.Wpf.RichEdit
Declaration
Event Data
The EncryptedFilePasswordRequested event's data class is EncryptedFilePasswordRequestedEventArgs. 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. |
DocumentName | Gets the name of the encrypted document. |
Password | Gets or sets the password used to encrypt the document. |
Remarks
The EncryptedFilePasswordRequested event allows you to specify a password in code using the Password property. If the given password is empty or invalid, the EncryptedFilePasswordCheckFailed event raises.
int tryCount = 4;
private void RichEditControl1_EncryptedFilePasswordRequested(object sender, EncryptedFilePasswordRequestedEventArgs e)
{
//Count the amount of attempts to enter the password
if (tryCount > 0)
{
tryCount--;
}
}
private void RichEditControl1_EncryptedFilePasswordCheckFailed(object sender, EncryptedFilePasswordCheckFailedEventArgs e)
{
//Analyze the error led to this event
switch (e.Error)
{
case RichEditDecryptionError.PasswordRequired:
if (tryCount > 0)
{
e.TryAgain = true;
e.Handled = true;
System.Windows.Forms.MessageBox.Show("You did not enter the password!", String.Format("{0} attempts left", tryCount));
}
else
e.TryAgain = false;
break;
case RichEditDecryptionError.WrongPassword:
if (tryCount > 0)
{
if (System.Windows.Forms.MessageBox.Show("The password is incorrect. Try Again?", string.Format("{0} attempts left", tryCount),
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
{
e.TryAgain = true;
e.Handled = true;
}
}
break;
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the EncryptedFilePasswordRequested event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.