Results 1 to 5 of 5

Thread: Combobox hot key? [Resolved]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    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.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this :
    VB Code:
    1. ComboBox1.Focus()
    2. SendKeys.Send("%{DOWN}")

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    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.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This is how to capture any combination of keys . Just replace the msgbox part with your handling method .

    VB Code:
    1. Private Sub ComboBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown
    2.         If e.Alt And e.KeyValue = Keys.P Then
    3.             MessageBox.Show("You pressed Alt + P")
    4.         End If
    5.     End Sub

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    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:
    1. Private Sub frmWhiteSlips_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    2.         If e.Alt And e.KeyValue = Keys.C Then
    3.             cboProject.DroppedDown = True
    4.             mblnHotKey = True
    5.         ElseIf e.Alt And e.KeyValue = Keys.M Then
    6.             cboMonth.DroppedDown = True
    7.         End If
    8.     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
  •  



Click Here to Expand Forum to Full Width