Skip to content

Allow html in label control w/ anchor tag. #1396

Closed

Description

@itg-assistant

Matthew Ferry asked 2018-02-27 01:59:02 UTC

If I have a label control with allowHtml = true, and .text of "Please click here to say hello world."

How can I get the event - like a linkClicked event - if they click just the portion of the text that is the anchor (i.e. the regular click gets fired for non anchor parts of the text)

Is this possible?  The htmlPanel h as ElementClicked which works for this purpose, but I'd be interested in doing this for label controls in particular.

Thoughts?

Thanks in advance,

Matthew

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Frank (ITG) answered 2018-02-27 08:48:08 UTC

    Hi Matthew,

    this can be accomplished by using the role property and handling the MouseClick event.

    Simply add a role attribute to the HTML hyperlink and query it as e.Role in your MouseClick event handler.
    Please note that the Click event handle does not have any arguments, so you need to use MouseClick or MouseDown.

    With using different role properties you could also have multiple links in a label and handle each link separately.

    Hope that helps.

    Best regards
    Frank

  2. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Matthew Ferry answered 2018-02-28 01:46:55 UTC

    Thank you - this solution works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    New FeatureA capability that does not exist yet.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions