Forum Discussion
Tony Furnivall
May 09, 2018Copper Contributor
Sequence of events in Excel ComboBox
I'm puzzled why the Change and CLick events are fired in reverse order, in an Excel ComboBox. Here's a situation: I have a ComboBox containing a list of items. In order to select one I click on ...
Tony Furnivall
Dec 28, 2022Copper Contributor
The solution I finally adopted was somewhat akin to capturing the Shift parameter on MouseDown and MouseUp. In that model we save the Shift value in an external variable, and then simply reference it during the Click or DoubleClick event.
So, in the case in point, we capture the 'fact' of the DropButton Click by setting a value in the Tag field (this keeps it internal to the control). Then by interrogating the Tag field we can determine if the Change event is fired by a Click on the list or by typing in the ComboBox text area.
It's messy - it removes the Tag from any other use (which was no loss for me), and requires set up and cleanup on the Enter and Exit events. However, it gave me most of what I needed! Another possibility I explored (which was Really Messy) was tombine a TextBox, a Button (for the DropDown) and a Listbox, and manage their visibility myself, rather than allowing Excel to do this.
I know CoomboBoxes are "legacy" controls, but I can't imagine how exposing the ListVisible property (which must be there to know whether to close the list or not!) would create problems.
Like most software, support does not generate revenue, and fixing 'old' problems is considered unglamorous.
How wrong can they be!
Tony
So, in the case in point, we capture the 'fact' of the DropButton Click by setting a value in the Tag field (this keeps it internal to the control). Then by interrogating the Tag field we can determine if the Change event is fired by a Click on the list or by typing in the ComboBox text area.
It's messy - it removes the Tag from any other use (which was no loss for me), and requires set up and cleanup on the Enter and Exit events. However, it gave me most of what I needed! Another possibility I explored (which was Really Messy) was tombine a TextBox, a Button (for the DropDown) and a Listbox, and manage their visibility myself, rather than allowing Excel to do this.
I know CoomboBoxes are "legacy" controls, but I can't imagine how exposing the ListVisible property (which must be there to know whether to close the list or not!) would create problems.
Like most software, support does not generate revenue, and fixing 'old' problems is considered unglamorous.
How wrong can they be!
Tony