Back to Devexpress

ShowFormEventArgs.Handled Property

windowsforms-devexpress-dot-xtrarichedit-dot-showformeventargs-c49f97e2.md

latest4.1 KB
Original Source

ShowFormEventArgs.Handled Property

Gets or sets whether an event was handled. If it was handled, the default actions are not required.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public bool Handled { get; set; }
vb
Public Property Handled As Boolean

Property Value

TypeDescription
Boolean

true if it was handled and the default dialog doesn’t need to be shown; otherwise, false.

|

Remarks

If the event parameter’s Handled property is set to true within a handler, then the default dialog will not be shown. Otherwise, the default dialog will be invoked after the custom actions within the handler have been performed.

Use the Handled property set to true with the ShowFormEventArgs.DialogResult parameter, to substitute a standard dialog with a custom one.

Example

This example demonstrates how handle the RichEditControl.SearchFormShowing event to replace the standard Find and Replace dialog with a custom dialog.

csharp
private void richEditControl1_SearchFormShowing(object sender, SearchFormShowingEventArgs e)
{
    string curWord = richEditControl.Document.GetText(richEditControl.Document.Selection);
    using (MySearchTextForm form = new MySearchTextForm(e.ControllerParameters, curWord))
    {
        e.DialogResult = form.ShowDialog();
        e.Handled = true;
    }
}
vb
Private Sub richEditControl1_SearchFormShowing(ByVal sender As Object, ByVal e As SearchFormShowingEventArgs)
Dim curWord As String = richEditControl.Document.GetText(richEditControl.Document.Selection)
Using form As New MySearchTextForm(e.ControllerParameters, curWord)
    e.DialogResult = form.ShowDialog()
    e.Handled = True
End Using
End Sub
csharp
using System.Drawing;
using DevExpress.XtraRichEdit.Forms;

namespace CustomDialogs
{
    public partial class MySearchTextForm : SearchTextForm
    {
        public MySearchTextForm(SearchFormControllerParameters controllerParameters, string searchWord)
            : base(controllerParameters)
        {
            lblFndDirection.Location = new Point (lblFndDirection.Location.X - 10, lblFndDirection.Location.Y);
            lblFndDirection.Text = "Direction:";
            cbFndSearchString.Text = searchWord;
            chbFndRegex.Enabled = false;
        }
    }
}
vb
Imports Microsoft.VisualBasic
Imports System.Drawing
Imports DevExpress.XtraRichEdit.Forms

Namespace CustomDialogs
    Partial Public Class MySearchTextForm
        Inherits SearchTextForm
        Public Sub New(ByVal controllerParameters As SearchFormControllerParameters, ByVal searchWord As String)
            MyBase.New(controllerParameters)
            lblFndDirection.Location = New Point (lblFndDirection.Location.X - 10, lblFndDirection.Location.Y)
            lblFndDirection.Text = "Direction:"
            cbFndSearchString.Text = searchWord
            chbFndRegex.Enabled = False
        End Sub
    End Class
End Namespace

See Also

ShowFormEventArgs Class

ShowFormEventArgs Members

DevExpress.XtraRichEdit Namespace