Control Enter and Mouseclick Events

timh

Well-known member
Joined
Nov 28, 2008
Messages
50
Programming Experience
Beginner
Next question...

I'm trying to cater for all eventualities and make data entry as swift as possible on my form.

To that end, I have set several combo boxes to "drop down" if the user tabs to them, by using the "Enter" event.

VB.NET:
    Private Sub sexComboBox_Enter(sender As System.Object, e As System.EventArgs) Handles sexComboBox.Enter, numberissuedbyComboBox.Enter, methodComboBox.Enter, feeComboBox.Enter
        If mainForm.isedit = False Then Exit Sub
        SendKeys.Send("%{DOWN}")
    End Sub

This works exactly as I want it to, that is until the user clicks on the control rather than tabbing to it. What happens then is that the combobox drops and then closes up immediately. I then have to click the box again to get it to drop down to select the item I want.

I've tried handling the "Mouseclick" event to bypass the "Enter" event, but that doesn't work because the "Enter" event fires first.

What I'm aiming for is: on entering the control, automatically drop the list down, unless the control has been entered by clicking on it.

I expect I'm missing something obvious, but any suggestions?

Thanks.
 
Thanks. That sort of works, but not entirely satisfactorily. For instance, if a combobox is dropped down and I then move to another combobox, the new one doesn't respond? Nor does the MouseLeave event appear to fire when I leave the control that is dropped down (I thought I could use that to roll the dropdown list back up). I think I'll simply stop trying to be clever.
 
Back
Top