Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
   [Expand]Getting Started
   [Expand]RichEditControl Document
   [Expand]Fields
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Printing
    Spell Checking
    AutoCorrect
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
    Traversing the Document
   [Expand]Visual Elements
    Services
    Events
    Commands
   [Expand]Member Tables
    Keyboard Shortcuts
    HTML Tag Interpretation
   [Collapse]Examples
    [Expand]Files
    [Expand]Text
    [Expand]Formatting
    [Expand]Styles
    [Expand]Lists
    [Expand]Pictures
    [Expand]Text Boxes
    [Expand]Tables
    [Expand]Layout
    [Collapse]Automation
      How to: Create a Table of Contents
      How to: Create a Table of Contents in Code
      How to: Add and Modify Fields
      How to: Handle the HyperlinkClick Event to Invoke the Custom Form
    [Expand]Search and Replace
    [Expand]Mail Merge
    [Expand]Spell Check
    [Expand]Export-Import
    [Expand]Printing
    [Expand]Protection
    [Expand]User Interface Customization
    [Expand]Miscellaneous
    [Expand]Commands
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap 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]Document Server
[Expand]Reporting
[Expand]Report 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. 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.
Tip

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.
    • Show Me

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

    • 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.
    • Show Me

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

  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.

    Show Me

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

  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.

    Show Me

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

How would you rate this topic?​​​​​​​