Like it

Showing posts with label Events. Show all posts
Showing posts with label Events. Show all posts

Saturday, July 9, 2011

Form's Keydown Event not Firing in VB.NET

How to enable Keydown, Keypress events for Windows forms (.NET)

If the Keydown, Keypress events etc are not fired in WinForms application, check if the KeyPreview is set



How to use Function Keys in VB.NET Windows Application





Capture Function Keys in VB.NET Windows Application

The following snippet might help you in capturing the Function Keys (F1 to F12) in a VB.NET application


Private Sub frmWinSamAppMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown 
Select Case e.KeyCode 
Case Keys.F1 
MessageBox.Show("Help is on the way") 
Case Keys.F5 
RefreshMethod() 
Case Keys.F9 
MessageBox.Show("You have pressed F9") 
End Select 
End Sub