c# - Press enter to click a LinkLabel -


if have linklabel on .net winform, there anyway can, when link label focused, press of enter key cause said linklabel click?

unfortunately doesn't seem expose keydown event.


edit

the simplest solution use previewkeydown, if happens google here.

you create own link label class extends linklabel , overrides onkeyup or onkeydown event capture enter keypress.

that save reproducing code every link label add form.

e.g.

public class linklabelex : linklabel {      protected override void onkeyup(keyeventargs e)     {         if (e.keycode == keys.enter)         {             e.suppresskeypress = true;             e.handled = true;             onlinkclicked(new linklabellinkclickedeventargs(new link(0, this.text.length)));         }         else         {             base.onkeyup(e);         }     }  } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -