RichEditControl.HyperlinkClick Event
Occurs when an end-user clicks the hyperlink to activate it.
Namespace: DevExpress.XtraRichEdit
Assembly: DevExpress.XtraRichEdit.v24.2.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 | Determines which modifier keys (SHIFT, CTRL, and ALT) were pressed to activate a hyperlink. |
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.
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);
}