windowsforms-devexpress-dot-xtraeditors-dot-labelcontrol-a2dfcc72.md
Occurs whenever an end-user clicks a hyperlink contained within the current LabelControl.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Action")]
public event HyperlinkClickEventHandler HyperlinkClick
<DXCategory("Action")>
Public Event HyperlinkClick As HyperlinkClickEventHandler
The HyperlinkClick event's data class is HyperlinkClickEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Link | Get or sets the URL of the clicked hyperlink. |
| MouseArgs | Gets or sets mouse coordinates calculated from the toolbar’s upper left corner. |
| Text | Gets or sets the hyperlink alt text. Note that modifying this text does not change the item caption. |
You can add hyperlinks to your LabelControl along with a regular text string. To do so, set the LabelControl.AllowHtmlString property to true and format the required text with the <href></href> tag. To see the list of all available tags, refer to HTML Text Formatting.
When an end-user clicks the hyperlink, the HyperlinkClick event occurs. Handle it to perform specific operations, depending on the link.
The following example shows how to format a LabelControl‘s text using HTML tags. HTML formatting is enabled with the LabelControl.AllowHtmlString property. To respond to end-user clicks on a hyperlink, the LabelControl.HyperlinkClick event is handled. The image below shows the result:
labelControl1.Text = "<size=14>Size = 14
" +
"<b>Bold</b> <i>Italic</i> <u>Underline</u>
" +
"<size=11>Size = 11
" +
"<color=255, 0, 0>Sample Text</color></size>" +
"<href=www.devexpress.com>Hyperlink</href>";
labelControl1.AllowHtmlString = true;
labelControl1.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
labelControl1.Appearance.Options.UseTextOptions = true;
labelControl1.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Vertical;
labelControl1.HyperlinkClick += LabelControl1_HyperlinkClick;
private void labelControl1_HyperlinkClick(object sender, DevExpress.Utils.HyperlinkClickEventArgs e) {
System.Diagnostics.Process.Start(e.Link);
}
labelControl1.Text = "<size=14>Size = 14
" + _
"<b>Bold</b> <i>Italic</i> <u>Underline</u>
" + _
"<size=11>Size = 11
" + _
"<color=255, 0, 0>Sample Text</color></size>
" + _
"<href=www.devexpress.com>Hyperlink</href>"
labelControl1.AllowHtmlString = True
labelControl1.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap
labelControl1.Appearance.Options.UseTextOptions = True
labelControl1.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Vertical
labelControl1.HyperlinkClick += LabelControl1_HyperlinkClick
Private Sub LabelControl1_HyperlinkClick(sender As Object, e As DevExpress.Utils.HyperlinkClickEventArgs) Handles LabelControl1.HyperlinkClick
System.Diagnostics.Process.Start(e.Link)
End Sub
See Also