VB 6 ComboBox auto open

280 pts.
Tags:
ComboBox
Visual Basic 6
how automatically open the combo on got focus

Answer Wiki

Thanks. We'll let you know when a new response is added.

To do that, you need to use the SendMessage function, from lib user32.

The first thing to do, is to declare the function, and use it in a procedure that will “open” the combo passed as a parameter. You can do this in a separate module (it can also be done in the form).

<pre>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
Private Const CB_SHOWDROPDOWN As Long = &H14F

Public Sub ShowDropDown(pobjCombo As ComboBox)
If pobjCombo.ListCount > 0 Then
SendMessage pobjCombo.hwnd, CB_SHOWDROPDOWN, 1, ByVal 0&
End If
End Sub</pre>

Then, you just need to call the ShowDropDown procedure, when the desired combo gets focused.

<pre>Private Sub Combo1_GotFocus()
ShowDropDown Combo1
End Sub</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following