nkwk Posted March 12, 2004 Posted March 12, 2004 Help .... im stuck In vb6 I would have done Select Case KeyCode Case vbKeyF5 msgbox "123" End Select But I dont know how to do it in .net Regards Nick Quote
Administrators PlausiblyDamp Posted March 12, 2004 Administrators Posted March 12, 2004 (edited) Private Sub Form1_KeyDown(ByVal sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown Select Case e.KeyCode Case Keys.F5 messagebox.Show("F5 was pressed"); End Select End Sub Edited February 27, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nkwk Posted March 18, 2004 Author Posted March 18, 2004 Hello mate, For some reason that only works on a blank form. The moment i start putting objects on it, it doesnt work anymore. Almost like the form isnt on top anymore. Any ideas? Regards, Nick Quote
TechnoTone Posted March 18, 2004 Posted March 18, 2004 You have to set the forms KeyPreview property to True. Then it will process all keypresses for it's child controls too. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
CattleRustler Posted March 19, 2004 Posted March 19, 2004 Yes, KeyPreview was a tricky little thing when I first started in vb.net ;) Quote mod2software Home of the VB.NET Class Builder Utility - Demo and Full versions available now!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.