Raj Kumar
Raj Kumar

Reputation: 63

Select or move dynamic Buttons using arrow key in vb.net

i have panel. dynamically i have created more than 10 buttons. the panel contains that all buttons. i want to select the any buttons using arrow up/Down/Left/Right? please give some idea's.enter image description here

Upvotes: 0

Views: 963

Answers (1)

Olivarsham
Olivarsham

Reputation: 1731

you can hookup the KeyDown Event of the button like this:

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

Upvotes: 1

Related Questions