|
-
Jan 8th, 2004, 03:13 PM
#1
Thread Starter
Frenzied Member
Combobox hot key? [Resolved]
Is there a way to get a combobox to have a hot key type action, so that the user can drop down the list from the keyboard w/o selecting anything? The best I can get is selecting the first item via the down arrow key. I want something that will perform the action of clicking on the combobox arrow. Thanks.
Last edited by salvelinus; Jan 9th, 2004 at 10:45 AM.
-
Jan 8th, 2004, 04:17 PM
#2
Sleep mode
Try this :
VB Code:
ComboBox1.Focus()
SendKeys.Send("%{DOWN}")
-
Jan 9th, 2004, 12:40 AM
#3
Thread Starter
Frenzied Member
Well thanks, I'll try that. I thought I'd read that Sendkeys wasn't available in .Net. I was going blindly through RaiseEvent and similar stuff. If it works I'll let you know.
I guess a question is how to capture the Alt-P combo to trigger that code.
-
Jan 9th, 2004, 05:12 AM
#4
Sleep mode
This is how to capture any combination of keys . Just replace the msgbox part with your handling method .
VB Code:
Private Sub ComboBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown
If e.Alt And e.KeyValue = Keys.P Then
MessageBox.Show("You pressed Alt + P")
End If
End Sub
-
Jan 9th, 2004, 10:44 AM
#5
Thread Starter
Frenzied Member
Thanks Pirate, that put me on the right path! I've got the form's KeyPreview set to True, and the code below did what I wanted. Heck of a lot easier than trying to raise events.
VB Code:
Private Sub frmWhiteSlips_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Alt And e.KeyValue = Keys.C Then
cboProject.DroppedDown = True
mblnHotKey = True
ElseIf e.Alt And e.KeyValue = Keys.M Then
cboMonth.DroppedDown = True
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|