Search code examples
c#eventsevent-handlingkeypress

Perform link label click with key press


I'm trying to create an event for a link label when the 'A' key is pressed. and the same when 'B' key is pressed, and so on until 'Z'. The name of the linklabel is ALinkLabel

From what I've researched, I think it would look a bit something like this

private void ALinkLabel_KeyPressed(object sender, KeyEventArg e)
{
   something in there
}

I'm not exactly sure, new to C#.

Any insight would be greatly appreciated


Solution

  • You are going to instead want to handle the KeyPressed on the parent form / user control and then use the PerformClick of the appropriate LinkLabel after casting it to IButtonControl.

    In order to find the matching LinkLabel you might consider storing the bound letter in the link label control's Tag property.