Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combox First Letter Issue 2

Status
Not open for further replies.

BJ1106

Programmer
Aug 24, 2006
30
US
Hi,

I am using Combox in my VB6 application. The style of the combobox is 0 - dropdown combo. the problem i have is every time when user typing the first letter, nothing happened. they have to type in twice of the first letter. For example, if they need to enter '1257'. they have to type in '1' twice, they can type in the rest. if they forgot, only '257' will show so they have to come back to correct. this only happened when the first time user click on the combobox. can anyone help?

Thanks a lot.
 
The reason i use the combox style 0 is because user wants to either type in or choose from the drop-down list.

Thanks.
 
I've only seen this when you automatically dropdown the combo on a keydown/keypress event.

Is that what is happening?



Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
I created a form, added a combo box with some selections. When I ran the program, I could click on a selection, and afterwards start typing in the box without the behavior you describe. Have you done this, or do you have some underlying code?
 
I have seen this issue when the user starts to type before the combobox actually has focus. Do you get this issue if the user clicks on the combobox (not the down arrow, but the data entry area)and then starts typing?
 
Hi Ron Repp,

Yes. you are right. since user wants to see the dropdown once they click on the combobox, i have 'SendKeys "%{down}"' in the gotfocus event and also in keypress/keydown event.
 
In a module
Code:
Public Declare Function SendMessage Lib "user32" _
       Alias "SendMessageA" _
       (ByVal hwnd As Long, _
       ByVal wMsg As Long, _
       ByVal wParam As Long, _
       lParam As Any) As Long

Public Const CB_SHOWDROPDOWN = &H14F
and in your form
Code:
Private Sub Combo1_GotFocus()
    Call SendMessage(Combo1.hwnd, CB_SHOWDROPDOWN, True, ByVal 0)
End Sub

Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
    Call SendMessage(Combo1.hwnd, CB_SHOWDROPDOWN, True, ByVal 0)
End Sub
I usually have problems with SendKeys and avoid it where possible.
 
Hi Golom,

It works! thank you very much.

thank you all.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top