RobBroekhuis
Technical User
I've listed this on the ActiveX controls forum, but this one gets more traffic, so please accept my apologies for crossposting.
I'm having some trouble with a ComboBox on an Excel worksheet. The behavior I'm looking for is to dynamically create the dropdown list items every time the user activates the combobox. I've tried to do this using the gotfocus event handler:
Private Sub PromisedFilter_gotfocus()
Dim PromLst(30) As String, PromCount As Integer
Dim i As Integer
MakingList = True 'signal to change event
PromisedFilter.Clear
PromisedFilter.AddItem "(all)"
PromCount = 0
...lots of code here to build PromLst array
For i = 1 To PromCount
PromisedFilter.AddItem PromLst(i)
Next i
MakingList = False
End Sub
Basically, this works, but about half the time, the on-screen display of the combobox will be messed up: the dropped-down list will be mostly gray, with just a single selection line at the top WITH ITS OWN SCROLL ARROWS (right underneath the dropdown arrow). Looks downright weird. Clicking on the list dropdown arrow to collapse the list, and then again to drop it down, returns the list to its normal display. However, I haven't been able to reproduce this "return to normal" programmatically. Am I trapping the wrong event (i.e., should I use an event that triggers BEFORE the combobox receives the focus? Which event might that be)? Or can I somehow "redraw" the control at the end of my event handler code? I tried a number of approaches, none successful.
I'd appreciate any pointers.
Rob
![[flowerface] [flowerface] [flowerface]](/data/assets/smilies/flowerface.gif)
I'm having some trouble with a ComboBox on an Excel worksheet. The behavior I'm looking for is to dynamically create the dropdown list items every time the user activates the combobox. I've tried to do this using the gotfocus event handler:
Private Sub PromisedFilter_gotfocus()
Dim PromLst(30) As String, PromCount As Integer
Dim i As Integer
MakingList = True 'signal to change event
PromisedFilter.Clear
PromisedFilter.AddItem "(all)"
PromCount = 0
...lots of code here to build PromLst array
For i = 1 To PromCount
PromisedFilter.AddItem PromLst(i)
Next i
MakingList = False
End Sub
Basically, this works, but about half the time, the on-screen display of the combobox will be messed up: the dropped-down list will be mostly gray, with just a single selection line at the top WITH ITS OWN SCROLL ARROWS (right underneath the dropdown arrow). Looks downright weird. Clicking on the list dropdown arrow to collapse the list, and then again to drop it down, returns the list to its normal display. However, I haven't been able to reproduce this "return to normal" programmatically. Am I trapping the wrong event (i.e., should I use an event that triggers BEFORE the combobox receives the focus? Which event might that be)? Or can I somehow "redraw" the control at the end of my event handler code? I tried a number of approaches, none successful.
I'd appreciate any pointers.
Rob
![[flowerface] [flowerface] [flowerface]](/data/assets/smilies/flowerface.gif)