Results 1 to 27 of 27

Thread: [RESOLVED] pull down the combo box

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] pull down the combo box

    I have textbox and combo box.

    How I can pull down the combo box, when I try insert the value in the textbox?

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: pull down the combo box

    If you go to the Code Bank section this forum, search for AutoComplete in that section. I believe you will find what you are looking for. Not that we can't explain it here, but it would take a lot of space and probably a lot of time.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: pull down the combo box

    I am not fill the combo box when I insert the value in the textbox. I just want, when I try typing something in the textbox, the combo box, automatically pull down.

  4. #4
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: pull down the combo box

    To pull down a combo box automatically,
    Code:
    SendMessage cmbHwnd,CB_SHOWDROPDOWN,1,0
    the above code will do no selection or anything. just a pull down

  5. #5
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: pull down the combo box

    Why do you want a pulldown? Just asking...

    Well, anyway just completing what Fazi started.


    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
                                                                    ByVal wMsg As Long, _
                                                                    ByVal wParam As Long, _
                                                                    lParam As Any) As Long
    Const CB_SHOWDROPDOWN = &H14F
    
    
    Private Sub Command1_Click()
        SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 1, 0
    End Sub
    Last edited by zynder; Oct 20th, 2007 at 12:20 PM.

  6. #6
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: pull down the combo box

    Thanks Zinder for the correction,
    to pull back the dropdown,
    Code:
    SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 0, 0

  7. #7
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: pull down the combo box

    hehehe you made a funny for completing it totally although the OP didn't answer me yet why he wants to open the combobox.

  8. #8
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: pull down the combo box

    As LaVolp stated, Matrik02 is looking to do an auto complete thing i guess.
    Question is not that clear.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: pull down the combo box

    I have problem here. The combo box drop down when I try type something in the textbox . When I clear the textbox, the combo box not pull back the dropdown. How I can pull back the dropdown when no value in the textbox?


    On Error GoTo error
    If Text2.Text <> 0 Then
    SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 1, 0
    ElseIf Text2.Text = "" Then
    SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 0, 0
    End If
    error:

  10. #10
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: pull down the combo box

    actually, on what event you call this SendMessage? imean Text1_Change() or Text1_Click() etc.
    Last edited by Fazi; Oct 21st, 2007 at 08:25 AM.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: pull down the combo box

    The dropdown will drop back up as soon as the control loses focus.

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: pull down the combo box

    Quote Originally Posted by Fazi
    actually, on what event you call this SendMessage? imean Text1_Change() or Text1_Click() etc.
    I put at text_Change(). The combo box not drop back after I clear the text in the textbox.How I can drop it back?When I try typing something in the textbox, combo box drop down but my mouse cursor disappear.How to appear the mouse cursor when the combo box drop down?

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: pull down the combo box

    Quote Originally Posted by Hack
    The dropdown will drop back up as soon as the control loses focus.
    It better understand if you provide the sample code.

  14. #14
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: pull down the combo box

    matrik, you if condition first statement is has a problem also.
    i just corrected it.

    Code:
    Private Sub Text2_Change()
    If Text2.Text <> "" Then
       SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 1, 0
    ElseIf Text2.Text = "" Then
       SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 0, 0
    End If
    
    End Sub
    ill check the curso.

  15. #15
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: pull down the combo box

    Why not just use a listbox??? Rather than trying to do algorithm gymnastics... Simply put, the combo box wasn't designed to work that way (square peg into round hole analogy).

  16. #16
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: pull down the combo box

    there is no problem with combo dropdown and retake.
    i have attched a woking project. curso is the only issue you have now
    Attached Files Attached Files

  17. #17
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: pull down the combo box

    Mouse cursor disappears, GUI lock. And what's the point of just dropping it it isn't an auto-complete feature (select/display matching item in dropdown list)?

  18. #18
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: pull down the combo box

    Quote Originally Posted by matrik02
    It better understand if you provide the sample code.
    There is no code as it isn't necessary. It is the default behavior of the combo box.

  19. #19

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: pull down the combo box

    Quote Originally Posted by Fazi
    there is no problem with combo dropdown and retake.
    i have attched a woking project. curso is the only issue you have now
    Thank you so much Fazi. The problem is, my mouse cursor disappear.I can only move my mouse without cursor. .Anyone now how to set a mouse cursor when the combo box drop down?

  20. #20

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: pull down the combo box

    Quote Originally Posted by leinad31
    Mouse cursor disappears, GUI lock. And what's the point of just dropping it it isn't an auto-complete feature (select/display matching item in dropdown list)?
    Actually I just want to drop down the combo box only when the user typing something on the textbox.When the combo box drop down, the user can choose the items on the combo box. That mean, user have two option either choose from combo box or typing something on combo box to let user choose the items from drop down combo box. The problem is, the the mouse cursor disappears and GUI lock. How to unlock the GUI and set the mouse cursor for combo box when the combo box drop down?



    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
                                                                    ByVal wMsg As Long, _
                                                                    ByVal wParam As Long, _
                                                                    lParam As Any) As Long
    Const CB_SHOWDROPDOWN = &H14F
    
    
    
    Private Sub Form_Load()
    Me.Combo1.AddItem "1"
    Me.Combo1.AddItem "2"
    End Sub
    
    Private Sub Text2_Change()
    If Text2.Text <> "" Then
       SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 1, 0
    ElseIf Text2.Text = "" Then
       SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 0, 0
       Me.SetFocus
    End If
    
    End Sub

  21. #21
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: pull down the combo box

    try
    SendMessage(hwnd,WM_SETCURSOR,0,0)

    not sure which hwnd

  22. #22

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: pull down the combo box

    Hi Fazi, try you use this using you attach file

    Code:
    Private Sub Text2_Change()
    If Text2.Text <> "" Then
       SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 1, 0
       
       Combo1.MousePointer = 1
        Combo1.SetFocus
    ElseIf Text2.Text = "" Then
       SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 0, 0
       Me.SetFocus
    End If
    
    End Sub

  23. #23
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: pull down the combo box

    Quote Originally Posted by matrik02
    Hi Fazi, try you use this using you attach file

    Code:
    Private Sub Text2_Change()
    If Text2.Text <> "" Then
       SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 1, 0
       
       Combo1.MousePointer = 1
        Combo1.SetFocus
    ElseIf Text2.Text = "" Then
       SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 0, 0
       Me.SetFocus
    End If
    
    End Sub
    This works just fine. I just tested it. Are you having a problem with it?

  24. #24
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: pull down the combo box

    matrik,
    sorry, it did not work. but this topic seems have beed discussed on the net.
    google for "SendMessage Mouse disappears" returned many results.
    pls check. i am about to leave.

  25. #25

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: pull down the combo box

    Nothing. I think I solved my problem. Thank you all

  26. #26
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: pull down the combo box

    Oh, Ok.

    Don't forget to resolve the thread then.

  27. #27
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: pull down the combo box

    any way, not sure how did you bring that mouse pointer
    there is a solution, but i have no time now,
    http://support.microsoft.com/default...b;en-us;326254

    Good Luck !

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