Autoexpand a combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    Autoexpand a combo box

    comboboxname = cboln03

    Is it possible to click a button and the combo box expand as if a user clicked the arrow?

    so click a button - cboln03 opens to reveal list of items.

    Thanks
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    You could try this (little sample I just wrote and tested - it appears to work)
    [CODE=vb]Combo1.SetFocus
    SendKeys "{F4}"[/CODE]

    Comment

    • lotus18
      Contributor
      • Nov 2007
      • 865

      #3
      Originally posted by Killer42
      You could try this (little sample I just wrote and tested - it appears to work)
      [CODE=vb]Combo1.SetFocus
      SendKeys "{F4}"[/CODE]
      Hi Killer42

      Can you explain to us what's the function of using F4? I really have no idea. LOL

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        When the focus is on a combobox, you can press the F4 key (also Alt-Down, I think) to expand the list.

        Comment

        • jamesd0142
          Contributor
          • Sep 2007
          • 471

          #5
          Originally posted by Killer42
          You could try this (little sample I just wrote and tested - it appears to work)
          [CODE=vb]Combo1.SetFocus
          SendKeys "{F4}"[/CODE]
          Thanks thats what i needed!

          could you use this sendkeys thingy to capture key press?

          say something like:
          [code=vbnet]
          if sendkeys.send(" {alt+a}") = true then
          'do something
          end if
          [/code]

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            I'm not familiar with the capabilities of VB.Net (I use the ten-year-old VB6) but as far as I know SendKeys is only for sending, not receiving.

            Comment

            • Freaky Chris
              New Member
              • Dec 2007
              • 24

              #7
              SendKeys does not allow for the processing of keys inputted, however it is possible to detect keyboard actions using keydown/keypress events on different objects. The example below demonstrates how.

              [CODE=vbnet]Private Sub textBox1_KeyDow n(sender As Object, e As System.Windows. Forms.KeyEventA rgs) Handles textBox1.KeyDow n

              If e.KeyCode == 65 Then
              ' Whatever you wish to do, note you can convert the key code to its ASCII char
              End If

              End Sub[/CODE]

              I hope this helps you with getting key input. Each character has its own decimal value and I'm not sure but I believe you can use Chr() to convert its decimal value into the ASCII character.

              Chris
              Last edited by Killer42; Dec 20 '07, 01:46 AM.

              Comment

              Working...