-2

i have a flyout as a login form, but whenever i presses the esc key the flyout will exit and i dont want that kind of thing so is there anyway to trap that esc key thingy in flyouts ? i did test this stuff but not of them works.

 Private Sub ItemAdd_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
    If login = True Then
        MsgBox("haha")
    End If
End Sub

Private Sub ItemAdd_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
    If login = True Then
        MsgBox("haha")
    End If
End Sub

Private Sub ItemAdd_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
    If e.KeyCode = Keys.Space Then
        MsgBox("haha")

    End If
End Sub

OR HOW CAN I DISABLE THE ESC KEY in a FORM ?

user3211476
  • 37
  • 1
  • 12
  • There are tons of examples for doing this around SOE. (ie. http://stackoverflow.com/questions/4442805/vb-net-key-combination?rq=1) In your code example it looks like you're already pretty close. Be sure you're forms KeyPreview property is set to true. – thetimmer Jun 20 '14 at 12:56
  • hmmm..tnx for the reply..i try that out..tnx – user3211476 Jun 20 '14 at 12:57

1 Answers1

1

I haven't tried this myself, but you give it a try:

Private Sub ItemAdd_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown

  If e.KeyCode = Keys.Escape Then
    e.Handled = True
  End If

End Sub
Visual Vincent
  • 18,045
  • 5
  • 28
  • 75