[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Spell Checking
    AutoCorrect Feature
    Track Changes
    Mail Merge
    Restrictions and Protection
   [Expand]Visual Elements
    Keyboard Shortcuts
    HTML Tag Support
      How to: Create a Table of Contents in Code
      How to: Handle the HyperlinkClick Event to Invoke the Custom Form
      How to: Retrieve the List of Document Fonts using the Visitor-Iterator Pattern
      How to: Highlight Document Syntax
      How to: Insert Dynamic Content
    [Expand]Search and Replace
    [Expand]Spell Check
    [Expand]Import and Export
    [Expand]UI Customization
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[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. The end-user can select the item from the pop-up list and it automatically replaces the hyperlink content.

Expanded Show Animation

To accomplish this task, perform the following actions.

  • Create a document with hyperlinks.
  • Create a custom form, implement it depending on your current needs and provide it with the members, allowing you to retrieve the selected item value and associate it with the hyperlink.
  • 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.

If you want to change the modifier key used to activate the hyperlink, specify the main form's HyperlinkOptions.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 about how to display a custom pop-up list by clicking a hyperlink.

  1. First, create a custom form with the ListBoxControl that will be shown when a hyperlink is clicked. In Visual Studio's Solution Explorer window, right-click your project and select “Add DevExpress Item | Form…” to add a skinable XtraForm. Then, open the Toolbox and drop the ListBoxControl onto the new form.

  2. Provide the custom form class with the following members.

    • Create two properties, EditValue and Range. The first property gets the value of the selected list item, the second property is used to point to the document range which will be replaced with the selected value.

    • Declare the Commit event, raised when the form is going to be invoked. This event is used to catch the moment when the item is selected from the list.

  3. In the main form class, handle the RichEditControl.HyperlinkClick event to create a new instance of a custom form and supply it with the start-up location and hyperlink range. The form's location is determined by the caret position, which can be accessed using the RichEditControl.GetBoundsFromPosition method.

  4. Finally, declare the Commit event handler which substitutes the document range obtained from the Range property with the selected item's value obtained from the EditValue property.

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