Back to Devexpress

TdxHyperlinkClickEventArgs.URI Property

vcl-cxcontrols-dot-tdxhyperlinkclickeventargs-586e555c.md

latest3.0 KB
Original Source

TdxHyperlinkClickEventArgs.URI Property

Specifies the target URI of the clicked hyperlink.

Declaration

delphi
property URI: string read; write;

Property Value

TypeDescription
string

The target URI of the clicked hyperlink.

|

Remarks

Use the URI property to identify the clicked hyperlink’s target URI or change it.

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.

delphi
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;
cpp
#include "System.StrUtils.hpp" // Declares the ContainsText global function
// ...

void __fastcall TMyForm::dxLayoutControl1Item1HyperlinkClick(TObject* Sender,
  TdxHyperlinkClickEventArgs *AArgs)
{
  if(ContainsText(AArgs->URI, "mailto")) // If the clicked hyperlink contains the "mailto" URI scheme
    AArgs->Handled = true; // Prevents hyperlink activation
}

void __fastcall TMyForm::FormCreate(TObject *Sender) // Associates all layout items with the declared handler
{
  for(int i = 0; i < dxLayoutControl1->AbsoluteItemCount; i++) // Iterates through all layout items
    dxLayoutControl1->AbsoluteItems[i]->OnHyperlinkClick = dxLayoutControl1Item1HyperlinkClick;
}

See Also

TdxHyperlinkClickEventArgs.Handled Property

TdxHyperlinkClickEventArgs Class

TdxHyperlinkClickEventArgs Members

cxControls Unit