Skip to main content
All docs
V25.1
  • TdxHyperlinkClickEventArgs Class

    Stores information on a hyperlink click event in a DevExpress control or its UI element.

    Declaration

    TdxHyperlinkClickEventArgs = class(
        TdxHyperlinkEventArgs
    )

    Remarks

    Hyperlink click events allow you to modify hyperlink activation behavior in DevExpress controls and their UI elements.

    Main API Members

    The list below outlines key members of the TdxHyperlinkClickEventArgs class. These members allow you to identify the target hyperlink and its parent UI element as well as prevent a user from activating the hyperlink.

    Button | Shift
    Allow you to identify the clicked mouse button and the state of modifier keys at the moment of event occurrence.
    Handled
    Allows you to prevent hyperlink activation.
    HyperlinkIndex
    Returns the index of the target hyperlink in the parent UI element’s message.
    Item
    Provides access to the parent UI element of the target hyperlink.
    Text
    Returns the target hyperlink’s anchor text.
    URI
    Allows you to identify the hyperlink’s target URI and change it.

    Code Examples

    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;  // 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;
    

    The code example in this section demonstrates handlers of OnHyperlinkClick and OnShowHyperlinkHint events. The OnHyperlinkClick event handler requires a user to hold down the Ctrl key to activate a hyperlink. The OnShowHyperlinkHint event handler changes all hyperlink hints to prompt a user to hold the Ctrl key for hyperlink activation.

    procedure TMyForm.dxFormattedLabel1PropertiesHyperlinkClick(Sender: TObject;
      AArgs: TdxHyperlinkClickEventArgs);  // Requires the Ctrl key for hyperlink activation
    begin
      if AArgs.Shift <> [ssCtrl] then  // If the Ctrl key is not held down
        AArgs.Handled := True;  // Prevents hyperlink activation
    end;
    
    procedure TMyForm.dxFormattedLabel1PropertiesShowHyperlinkHint(Sender: TObject;
      AArgs: TdxShowHyperlinkHintEventArgs);  // Changes all hyperlink hints
    var
      AHintPrefix, AHintURI: string;
    begin
      AHintPrefix := 'Ctrl-click to navigate to ';
      AHintURI := AArgs.URI.Remove(0, 8);  // Removes the URI scheme from the hyperlink hint
      AArgs.Hint := AHintPrefix + AHintURI;  // Redefines the hyperlink hint
    end;
    

    VCL Shared Libraries: A Custom Hyperlink Hint

    Direct TdxHyperlinkClickEventArgs Class Reference

    The TdxHyperlinkClickEvent procedural type references a TdxHyperlinkClickEventArgs object as the AArgs parameter.

    Inheritance

    See Also