DropDown Box Mouse Down Event

R

Roy Lasris

Is there a way to distinguish a click to drop down a combo-box list (to reveal
its contents) from a click to select an item in the list?

I have populated a combobox with the names of documents that I may wish to
open. I also have written a mouse-down routine such that if the shift button
was pressed, a copy of the file, not the original, would be opened. When I
click the down arrow at the right of the list to drop down the list to see its
contents, the mouse-down routine fires and I lose control.

Is there a special code or setting that I can check for to distinguish between
a press on the down arrow (to reveal the list) and a press on a 'real item' in
the list?

Thanks.
Roy
 
J

Jonathan West

Hi Roy

The DropButtonClick event is fired when you click the down arrow at the
right.

The Change event is fired when you change the selected item, either by
clicking it or by selecting it using the cursor keys, or by typing in your
own text if it is set up as a combobox rather than a plain dropdown listbox

The Click event is fired when you click an item in the list with the mouse
or select it with the cursor keys.

A simple form with one combobox and the following code will allow you to see
how it all works.

Private Sub ComboBox1_Change()
MsgBox "Change event"
End Sub

Private Sub ComboBox1_Click()
MsgBox "Click event"
End Sub


Private Sub ComboBox1_DropButtonClick()
MsgBox "DropButtonClick event"
End Sub

Private Sub UserForm_Initialize()
ComboBox1.List = Split("a b c d e f g h j k", " ")
End Sub
 
R

Roy Lasris

Thanks. That helped. I had a mousedown event also attached to the combobox and
your help led me to determine that the mouse down event was triggered before
the dropdownclick event.
This get confusing sometimes. I converted the mousedown to a mouseup event and
it all works hunky dorey, so far.

Thanks again,

Roy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top