I had written some code for a client using the onChange and onKeyPress events of a ComboBox to be able to determine when the user had simply typed some text in, or whether they had selected an item from the dropdown list using the dropdown event. This was because the customer wanted some very specific behavior of the form in those different circumstances.
How did I do it?
Well, I have a class on the dropdown box that gets loaded with the form.
The class sets up it’s event handlers on the target combo box to listen for events.
For a bound combobox, the Change event happens whether you type in the box or select from the dropdown, BUT, only the KeyPress event occurs if you are typing in the box. The KeyPress event does not trigger if you manage to use the key combo to make the combo dropdown and use the arrows to select the item either!
Using this knowledge learned through experimentation, I was able to setup KeyPress to trigger a variable in the class to indicate the change was being made by typing. This would trigger every time they pressed a key and would not force the trigger if they had hit enter or tab.
The Change event would check to see if the KeyPress event had just triggered. If not, it just knows that the change occurred based on a selection from the dropdown rather than a keyboard event and so will reset the trigger appropriately. That way, the trigger is ready to be checked later on. If the last change to the control was made through typing, the variable is set to true, if not, the variable is set to false.
However, make sure you set the event handlers on the control to use your object / routines! It ends up being completely useless if you forget to do that!