Back to Devexpress

RichEditControl.HyperlinkFormShowing Event

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-f8ee561c.md

latest6.0 KB
Original Source

RichEditControl.HyperlinkFormShowing Event

Occurs before the Edit Hyperlink dialog is invoked.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public event HyperlinkFormShowingEventHandler HyperlinkFormShowing
vb
Public Event HyperlinkFormShowing As HyperlinkFormShowingEventHandler

Event Data

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

PropertyDescription
ControllerParametersGets the information for initializing the Edit Hyperlink 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 HyperlinkFormShowing event to perform any actions prior to the Edit Hyperlink dialog being shown. For example, you can substitute the standard dialog with a custom one and set the ShowFormEventArgs.Handled property to true , to prevent default event handling.

Example

This example demonstrates how to replace the standard Hyperlink dialog with a custom form using the RichEditControl.HyperlinkFormShowing event.

csharp
private void richEditControl1_HyperlinkFormShowing(object sender,HyperlinkFormShowingEventArgs e)
{
    using (MyHyperlinkForm form = new MyHyperlinkForm(e.ControllerParameters))
    {
        e.DialogResult = form.ShowDialog();
        e.Handled = true;
    }
}
vb
Private Sub richEditControl1_HyperlinkFormShowing(ByVal sender As Object, ByVal e As HyperlinkFormShowingEventArgs)
    Using form As New MyHyperlinkForm(e.ControllerParameters)
        e.DialogResult = form.ShowDialog()
        e.Handled = True
    End Using
End Sub
csharp
using System;
using DevExpress.XtraRichEdit.Forms;

namespace CustomDialogs {
    class MyHyperlinkForm : HyperlinkForm {
        public MyHyperlinkForm(HyperlinkFormControllerParameters controllerParameters)
            : base(controllerParameters)
        {
            btnEditAddress.EditValueChanged += new EventHandler(btnEditAddress_EditValueChanged);
            btnEditAddress.LostFocus += new EventHandler(btnEditAddress_LostFocus);
        }

        void btnEditAddress_LostFocus(object sender, EventArgs e) {
            this.btnEditAddress.Text = Controller.NavigateUri;
        }

        void btnEditAddress_EditValueChanged(object sender, EventArgs e) {
            Controller.NavigateUri = ValidateUrl(btnEditAddress.Text);
            this.btnOk.Enabled = true;
        }

        private string ValidateUrl(string p) {
            string s = p.Replace("devexpres.com", "devexpress.com");
            return s;
        }

    }
}
vb
Imports Microsoft.VisualBasic
Imports System
Imports DevExpress.XtraRichEdit.Forms

Namespace CustomDialogs
    Friend Class MyHyperlinkForm
        Inherits HyperlinkForm
        Public Sub New(ByVal controllerParameters As HyperlinkFormControllerParameters)
            MyBase.New(controllerParameters)
            AddHandler btnEditAddress.EditValueChanged, AddressOf btnEditAddress_EditValueChanged
            AddHandler btnEditAddress.LostFocus, AddressOf btnEditAddress_LostFocus
        End Sub

        Private Sub btnEditAddress_LostFocus(ByVal sender As Object, ByVal e As EventArgs)
            Me.btnEditAddress.Text = Controller.NavigateUri
        End Sub

        Private Sub btnEditAddress_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs)
            Controller.NavigateUri = ValidateUrl(btnEditAddress.Text)
            Me.btnOk.Enabled = Not String.IsNullOrEmpty(Me.btnEditAddress.Text)
        End Sub

        Private Function ValidateUrl(ByVal p As String) As String
            Dim s As String = p.Replace("devexpres.com", "devexpress.com")
            Return s
        End Function

    End Class
End Namespace

See Also

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

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace