0

are there any ways to make linkLabel (.net 4.0) working as simple hyperlink on right mouse click - i mean to open a menu with "open in new tab", "open in new window" and so on.

if not, is there any way to develop custom control that will act like this?

actually i just need to be able to encapsulate simple hyperlink in some kind of control.

Boltosaurus
  • 2,138
  • 3
  • 21
  • 33

1 Answers1

1

On mouse down event for your link label, when you identify that its right mouse button, Open up a context menu and show up the options you wish to show.

private void OnMyLinkLableMouseDownEvent(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        //Show menu with required options
    }
}

If you plan to use this at multiple places in your application, then create a derived type from link label and add this event handler to it

Thanks to Hans Passant: you can also use ContextMenu(or ContextMenuStrip property not sure which one) if menu options are never going to change for different instances of LinkLabel.

Community
  • 1
  • 1
Maheep
  • 5,539
  • 3
  • 28
  • 47