Back to Devexpress

RichEditControl.SearchFormShowing Event

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-5b6ec0d6.md

latest5.7 KB
Original Source

RichEditControl.SearchFormShowing Event

Occurs when a search form is invoked before it is displayed.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public event SearchFormShowingEventHandler SearchFormShowing
vb
Public Event SearchFormShowing As SearchFormShowingEventHandler

Event Data

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

PropertyDescription
ActivePageObtains what tab of the Find and Replace dialog ( Find or Replace ) is active.
ControllerParametersGets the information for initializing the Find and Replace dialog controls.
DialogResultGets or sets the return value of a dialog box. Inherited from ShowFormEventArgs.
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 SearchFormShowing event to perform the required actions before a search form is displayed. Use the SearchFormShowingEventArgs.ActivePage property of the event’s argument to determine what tab is active on the search form - Find or Replace.

Note

The RichEditControl.ShowSearchForm and RichEditControl.ShowReplaceForm methods trigger the SearchFormShowing event.

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

How to: Customize the Hyperlink Form

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace