Back to Devexpress

MapControl.HyperlinkClick Event

windowsforms-devexpress-dot-xtramap-dot-mapcontrol-2c44823f.md

latest3.7 KB
Original Source

MapControl.HyperlinkClick Event

Occurs when a hyperlink on a map is clicked.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public event HyperlinkClickEventHandler HyperlinkClick
vb
Public Event HyperlinkClick As HyperlinkClickEventHandler

Event Data

The HyperlinkClick event's data class is HyperlinkClickEventArgs. The following properties provide information specific to this event:

PropertyDescription
LinkGet or sets the URL of the clicked hyperlink.
MouseArgsGets or sets mouse coordinates calculated from the toolbar’s upper left corner.
TextGets or sets the hyperlink alt text. Note that modifying this text does not change the item caption.

Remarks

In the following code snippet, the HyperlinkClick event occurs when a user clicks a MapCustomElement while simultaneously holding down Ctrl:

csharp
using DevExpress.XtraMap;
using System.Windows.Forms;

namespace MapApp {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm {
        public Form1() {

            MapControl map = new MapControl();
            //...

            var v_layer = new VectorItemsLayer();
            var itemStorage = new MapItemStorage();
            var customElement = new MapCustomElement() {
                Location = new GeoPoint(50, 50),
                AllowHtmlText = true,
                Text = "<a href='https://devexpress.com'>Click me</a>"
            };
            itemStorage.Items.Add(customElement);
            v_layer.Data = itemStorage;
            map.Layers.Add(v_layer);

            map.HyperlinkClick += Map_HyperlinkClick;
        }

        private void Map_HyperlinkClick(object sender, DevExpress.Utils.HyperlinkClickEventArgs e) {
            // Do something
        }
    }
}
vb
Imports DevExpress.XtraMap
Imports System.Windows.Forms

Namespace MapApp
    Public Partial Class Form1
        Inherits DevExpress.XtraEditors.XtraForm
        Public Sub New()

            Dim map As MapControl = New MapControl()
            ' ...

            Dim v_layer = New VectorItemsLayer()
            Dim itemStorage = New MapItemStorage()
            Dim customElement = New MapCustomElement() With {
                .Location = New GeoPoint(50, 50),
                .AllowHtmlText = True,
                .Text = "<a href='https://devexpress.com'>Click me</a>"
            }
            itemStorage.Items.Add(customElement)
            v_layer.Data = itemStorage
            map.Layers.Add(v_layer)

            AddHandler map.HyperlinkClick, AddressOf Map_HyperlinkClick
        End Sub

        Private Sub Map_HyperlinkClick(sender As Object, e As DevExpress.Utils.HyperlinkClickEventArgs)
            ' do something
        End Sub
    End Class
End Namespace

See Also

MapControl Class

MapControl Members

DevExpress.XtraMap Namespace