[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
   [Expand]Fields
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Printing
    AutoCorrect
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
    Traversing the Document
   [Expand]Visual Elements
    Services
    Events
    Commands
    HTML Tag Support
   [Collapse]Examples
    [Expand]UI Customization
    [Expand]Files
    [Expand]Text
    [Expand]Formatting
    [Expand]Styles
    [Expand]Lists
    [Expand]Pictures
    [Expand]Text Boxes
    [Expand]Tables
    [Expand]Document Elements
    [Expand]Layout
    [Collapse]Automation
      How to: Insert a Field to a Document
      How to: Create a Table of Contents
      How to: Create TOC for Special Cases
      How to: Create a Table of Contents in Code
      How to: Handle the HyperlinkClick Event to Invoke the Custom Form
     Spell Check
    [Expand]Export
    [Expand]Printing
    [Expand]Protection
    [Expand]Commands
    [Expand]Miscellaneous
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Handle the HyperlinkClick Event to Invoke the Custom Form

The following example demonstrates how to manually implement complex hyperlink behavior by handling the RichEditControl.HyperlinkClick event. In this example, this event handler is used to invoke a form with the data list. An end-user can select the desired item from the pop-up list. The value of the selected item automatically replaces the hyperlink content.

Expanded Show Animation

To accomplish this task, perform the following actions.

  • Create a document with hyperlinks.
  • Implement a custom form depending on your current needs and provide it with the members allowing you to retrieve the selected item value, associate it with the hyperlink and determine the form's startup location.
  • Handle the main form's RichEditControl.HyperlinkClick event to invoke the created form. In this event handler, call the SubDocument.Replace method to substitute the hyperlink content with the desired value.
Tip

If you want to change the modifier key used to activate the hyperlink, specify the main form's DXRichEditHyperlinkOptions.ModifierKeys property. You can select any of the available keys or set the property to None to activate the hyperlink by a click.

The steps below provide more detailed information on how to display a custom pop-up list by clicking a hyperlink.

Expanded Custom Form

  1. First, create a custom form with the ListBoxEdit, which will be shown when a hyperlink is clicked. In Visual Studio's Solution Explorer window, right-click your project and select “Add | User Control…”. Then, open the Toolbox and drop the ListBoxEdit onto the new form.
  2. Create two properties, EditValue and Range. The first property gets the value of the selected list item; the second property is used to refer to the document range which will be replaced with the selected value.
  3. Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T488029.

  4. Additionally, add the OwnerWindow property of a FloatingContainer class. This property allows you to set the startup position of a custom form.
  5. Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T488029.

  6. Declare the Commit event, which is raised when the form is going to be invoked. This event is used to catch the moment when an item is selected from the list.
  7. Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T488029.

Expanded Main Form

  1. In the main form class, handle the RichEditControl.HyperlinkClick event as shown in the code snippet below.

    Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T488029.

  2. Implement a method which determines the form's startup location relative to the caret position (can be accessed using the RichEditControl.GetBoundsFromPosition method).

    Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T488029.

  3. Finally, declare the Commit event handler as follows.

    Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T488029.

Is this topic helpful?​​​​​​​