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 Tip You can call the |
AArgs | TdxHyperlinkClickEventArgs | Provides access to information on the hyperlink click event that occurred in the UI element accessible through the For example, you can set the |
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 correspondingOnHyperlinkClick
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 andAArgs
.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.
Code Example: Prevent Hyperlink Activation in Layout Items
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.