Hello friends,

I have some weired problem. Basically, I have developed one form which is generic and display different views. On that form I have used Close button. Alphabet E is short-cut for closing the form (i.e. mnemonic functionality).

During execution of the form, when I press "E" on that form, my form closes automatically. As per my understanding mnemonic works with Alt control only. I am not sure if I am missing any properties that should be set so that this problem is resolved.

Kindly let me know regarding it.

Thanks
Dev

In vb.net I set the KeyPreview for the form to True and use the KeyUp event for such matters.

Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
      If e.Alt And e.KeyValue = Keys.E Then
         'enter the code you want to use to close the form
         Me.Close()
      End If
   End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.