Search code examples
winformstextboxkeyboard-shortcuts

How do I connect a keyboard shortcut to a text box?


I have two labels:

"Source Directory:" & "Target Directory:"

and two text boxes:

"tbSource" & "tbTarget"

I have added a shortcut to each text box

"Alt + S" & "Alt + T"

This works fine, but if I try to add underscores to the labels

"&Source..." & "&Target..."

it breaks down. With the underscores only the first text box (tbSource) is ever selected. (With both shortcuts)

What am I doing wrong?


Solution

  • Jimi's answer is correct:

    "Since your Labels use mnemonics, you just need to make sure that the TabIndex of your TextBoxes is set to the related Label's TabIndex + 1."