Skip to main content
All docs
V24.2

TdxHyperlinkClickEvent Type

The procedural type for hyperlink click events in DevExpress controls and their UI elements.

Declaration

TdxHyperlinkClickEvent = procedure(Sender: TObject; AArgs: TdxHyperlinkClickEventArgs) of object;

Parameters

Name Type Description
Sender TObject

Provides access to the control or UI element that raised the hyperlink click event.

Cast this parameter value to the corresponding terminal control or UI element class to access all public API members. Refer to the following section for detailed information on Sender types in different DevExpress products: Accessible Event Parameters.

Tip

You can call the Sender.ClassType function or use any other RTTI functionality to identify the actual control or UI element type.

AArgs TdxHyperlinkClickEventArgs

Provides access to information on the hyperlink click event that occurred in the UI element accessible through the Sender parameter.

For example, you can set the AArgs.Handled property to True to prevent hyperlink activation.

Remarks

You can handle this event to implement a custom response to a click on a hyperlink defined in a formatted message, label, or UI element caption in a DevExpress control. For example, you can prevent users from activating certain hyperlinks or execute custom code in response to a click on a hyperlink.

Event Occurrence

This event occurs every time a user clicks a hyperlink defined in a formatted message, label, or UI element caption.

Accessible Event Parameters

The following parameters are accessible within a hyperlink click event:

Sender

Provides access to the control or UI element that raised the hyperlink click event. The Sender parameter type depends on the class that declares the corresponding OnHyperlinkClick event:

Formatted Label Editors
The actual Sender type is TdxFormattedLabel or TdxDBFormattedLabel.
Layout Control
Sender is a terminal TdxCustomLayoutItem class descendant instance (at the layout item level) or a TdxLayoutControl instance (at the layout control level).
AArgs

Provides access to information related to the hyperlink click event that occurred and allows you to prevent hyperlink activation. You can use AArgs.Button and AArgs.Shift to identify the clicked mouse button and the state of modifier keys at the moment of event occurrence.

Refer to the TdxHyperlinkClickEventArgs class description for detailed information on all options accessible within a hyperlink click event handler.

The code example in this section demonstrates OnHyperlinkClick and OnCreate event handlers. The OnHyperlinkClick event handler prevents users from activating a hyperlink that contains the MAILTO URI scheme. The OnCreate event handler associates the OnHyperlinkClick event handler with all layout items at startup.

This scenario can be useful if you define layout item captions at runtime.

uses
  System.StrUtils;  // This unit declares the ContainsText global function
// ...

procedure TMyForm.dxLayoutControl1Item1HyperlinkClick(Sender: TObject;
  AArgs: TdxHyperlinkClickEventArgs);
begin
  if ContainsText(AArgs.URI, 'mailto') then  // If the clicked hyperlink contains the "mailto" URI scheme
    AArgs.Handled := True;  // Prevents hyperlink activation
end;

procedure TMyForm.FormCreate(Sender: TObject);  // Associates all layout items with the declared handler
var
  I: Integer;
begin
  for I := 0 to dxLayoutControl1.AbsoluteItemCount - 1 do  // Iterates through all layout items
    dxLayoutControl1.AbsoluteItems[I].OnHyperlinkClick := dxLayoutControl1Item1HyperlinkClick;
end;

Direct TdxHyperlinkClickEvent Type References

The following events reference the TdxHyperlinkClickEvent procedural type:

TdxCustomFormattedLabelProperties.OnHyperlinkClick
Allows you to respond to a click on a hyperlink or prevent hyperlink activation.
TdxCustomLayoutItem.OnHyperlinkClick
Allows you to respond to a click on a hyperlink or prevent hyperlink activation.
TdxCustomLayoutControl.OnHyperlinkClick
Allows you to respond to a click on a hyperlink in a layout item caption or prevent hyperlink activation.
See Also