使用vb.net中的箭头键选择或移动动态按钮

时间:2016-02-26 06:54:10

标签: vb.net

我有小组。动态我创建了10个以上的按钮。面板包含所有按钮。我想使用向上/向下/向左/向右箭头选择任何按钮? 请给出一些想法。enter image description here

1 个答案:

答案 0 :(得分:1)

你可以像这样连接按钮的KeyDown Event

Public Sub DesignPane_KeyDown(sender As Object, e As KeyEventArgs)
  If e.KeyCode = Keys.Down Then
    txtBox.Location.Y += 1
  ElseIf e.KeyCode = Keys.Right Then
    txtBox.Location.X += 1
  ElseIf e.KeyCode = Keys.Up Then
    txtBox.Location.Y -= 1
  ElseIf e.KeyCode = Keys.Left Then
    txtBox.Location.X -= 1
  End If
End Sub