Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

combo boxes

I have noticed that using the up/down arrow keys when a combo box is pulled down generates the click event. I want the click event to be generated only if the user clicks on the item with the mouse or presses the ENTER key. How can I overcome this problem?
0
brl
Asked:
brl
  • 2
1 Solution
 
roysterCommented:
Dim ClickFlag As Boolean

Private Sub Combo1_Click()
If ClickFlag = False Then Exit Sub
ClickFlag = False
End Sub

Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 40 Or KeyCode = 38 Then Exit Sub
ClickFlag = True
End Sub

0
 
roysterCommented:
This will work better:
Dim ClickFlag As Boolean

Private Sub Combo1_Click()
If ClickFlag = True Then ClickFlag = False: Exit Sub 'reject if arrows used
'enter click code here

End Sub

Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
ClickFlag = False
If KeyCode = 40 Or KeyCode = 38 Then ClickFlag = True
If KeyCode = 13 Then Combo1_Click
End Sub

0
 
brlAuthor Commented:
royster,

Thank you. I did try it. Seems to do what I want. I appreciate the quick repsonse.

brl.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now