Domanda

MessageBox don't show when I click this form and pressed some button on keyboard.

Private Sub MainForm_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Me.KeyPress
    MessageBox.Show(e.KeyChar.ToString)
End Sub
È stato utile?

Soluzione

set the KeyPreview property of the form to true

Altri suggerimenti

change Me.KeyPress to MyBase.KeyPress ... this will work

Private Sub MainForm_KeyPress(sender As Object, e As KeyPressEventArgs) Handles MyBase.KeyPress
    MessageBox.Show(e.KeyChar.ToString)
End Sub
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top