I have textbox and combo box.
How I can pull down the combo box, when I try insert the value in the textbox?
Printable View
I have textbox and combo box.
How I can pull down the combo box, when I try insert the value in the textbox?
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.
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.
To pull down a combo box automatically,
the above code will do no selection or anything. just a pull down :DCode:SendMessage cmbHwnd,CB_SHOWDROPDOWN,1,0
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
Thanks Zinder for the correction,
to pull back the dropdown,
Code:SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 0, 0
hehehe you made a funny for completing it totally although the OP didn't answer me yet why he wants to open the combobox.
As LaVolp stated, Matrik02 is looking to do an auto complete thing i guess.
Question is not that clear.
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?
Quote:
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:
actually, on what event you call this SendMessage? imean Text1_Change() or Text1_Click() etc.
The dropdown will drop back up as soon as the control loses focus.
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?Quote:
Originally Posted by Fazi
It better understand if you provide the sample code.Quote:
Originally Posted by Hack
matrik, you if condition first statement is has a problem also.
i just corrected it.
ill check the curso.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
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).
there is no problem with combo dropdown and retake.
i have attched a woking project. curso is the only issue you have now :)
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)?
There is no code as it isn't necessary. It is the default behavior of the combo box.Quote:
Originally Posted by matrik02
Thank you so much Fazi. The problem is, my mouse cursor disappear.I can only move my mouse without cursor.:D .Anyone now how to set a mouse cursor when the combo box drop down?Quote:
Originally Posted by Fazi
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?Quote:
Originally Posted by leinad31
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
try
SendMessage(hwnd,WM_SETCURSOR,0,0)
not sure which hwnd :p
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?Quote:
Originally Posted by matrik02
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.
Nothing. I think I solved my problem. Thank you all :wave:
Oh, Ok.
Don't forget to resolve the thread then. :)
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 !