[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].NET Core 3 Support
 [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
    Hyphenation
    AutoCorrect
    Track Changes
    Mail Merge
    Restrictions and Protection
   [Expand]Visual Elements
    Services
    Events
    Commands
    HTML Tag Support
   [Collapse]Examples
    [Expand]UI Customization
    [Expand]Files
    [Expand]Text
    [Expand]Formatting
    [Expand]Styles
    [Expand]Pictures
    [Expand]Text Boxes
    [Expand]Tables
    [Expand]Layout
    [Collapse]Automation
      How to: Create a Table of Contents in Code
      How to: Handle the HyperlinkClick Event to Invoke the Custom Form
      How to: Use the Visitor-Iterator Pattern to Retrieve the List of Document Fonts
      How to: Highlight Document Syntax
      How to: Insert Dynamic Content
     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]Gantt 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]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

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. Additionally, add the OwnerWindow property of a FloatingContainer class. This property allows you to set the startup position of a custom form.

  4. 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.

Expanded Main Form

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

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

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

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