RichEditControl.HyperlinkClick Event
Occurs when an end-user clicks the hyperlink to activate it.
Namespace: DevExpress.XtraRichEdit
Assembly: DevExpress.XtraRichEdit.v19.1.dll
Declaration
Event Data
The HyperlinkClick event's data class is HyperlinkClickEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Alt | Indicates whether the ALT key was pressed. |
Control | Indicates whether the CTRL key was pressed. |
Handled | Gets or sets whether the default action associated with the hyperlink click is required. |
Hyperlink | Gets a clicked hyperlink. |
ModifierKeys | Gets the modifier flags for a hyperlink click. The flags indicate which combination of CTRL, SHIFT, and ALT keys was pressed. |
Shift | Indicates whether the SHIFT key was pressed. |
Remarks
Handle this event to perform a custom action that depends on hyperlink properties. By default, activating a hyperlink results in navigating to the location specified by the Hyperlink.NavigateUri or the Hyperlink.Anchor property values.
In the code sample below, 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. Refer to the How to: Handle the HyperlinkClick Event to Invoke the Custom Form for a complete example.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-handle-the-hyperlink-click-event-t437501
public Hyperlink activeLink;
void OnHyperlinkClick(object sender, HyperlinkClickEventArgs e)
{
activeLink = e.Hyperlink;
SelectProductForm form = new SelectProductForm(products);
// Set the Commit event handler:
form.Commit += OnProductFormCommit;
//Set the Range property to the hyperlink range:
form.Range = activeLink.Range;
//Set the Location property to specify the location where the form is going to be invoked:
form.Location = GetFormLocation();
form.Show();
e.Handled = true;
}
//This method places the form to the right of the cursor position:
Point GetFormLocation()
{
DocumentPosition position = this.richEditControl1.Document.CaretPosition;
Rectangle rect = this.richEditControl1.GetBoundsFromPosition(position);
Point location = new Point(rect.Right, rect.Bottom);
Point localPoint = Units.DocumentsToPixels(location, this.richEditControl1.DpiX, this.richEditControl1.DpiY);
return this.richEditControl1.PointToScreen(localPoint);
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the HyperlinkClick event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.