Link to home
Start Free TrialLog in
Avatar of JHoeger
JHoeger

asked on

Is there a method of updating a combobox (style 2) box using both mouse clicks OR arrow keys?

Hi,
My last question was how to get my user to click on a combobox (style 2) and have the combobox.text update.  The simple answer was to use the combobox_click event.  I couldn't believe I didn't think of it earlier and changed every combobox on the form.  Everything worked super!  Just click on combobox1 and Presto, it accepts the highlighted value and the next combobox populates and gets the focus. Could life be any easier?  
Then I tried using the form using only the arrow keys on the keyboard.  Each time I press the "up", it triggers the "click_event" and really makes me sad :(.  I had to take out all the click_event procedures because I can't guarantee that my end users will only use either the keyboard or a mouse.

My program will be used on notebooks (mice suck on notebooks), and the arrow keys and "tab" will be used a lot.  On desktops (with a regular mouse), using a mouse is easier.  Unfortunately when you click the highlighted item with the mouse, the dropdown list closes and the control just sits there (waiting for you to trigger the "lost focus" event).

Can I have it both ways?  Can my users switch between using a mouse and using arrow keys?  I've tried a .dll called MsgHook and couldn't get it to work with my program.

Thanks in advance,

Jim Hoeger
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

I think you can set a flag to True on the keydown and keyup events of combo box.
On the click event check this value and exit sub, otherwise run the click event normally.
If you need some code, i can post it.
You can use the Keypress event of the ComboxBox to determine if the user is using the keyboard or the mouse.
If the KeyPress event is triggered you can perhaps set the Form's Tag property to "Keyboard".

Then in the ComboBox Click event you can first see if the Forms's tag property is "Keyboard", if it is then you don't process the Click event (just Exit the Sub).

Let me know if you need more help.

Regards,
Grant.
ASKER CERTIFIED SOLUTION
Avatar of PeteD
PeteD

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
qsc001 and PeteD,
Sorry but...
Did you read the previous comment before post yours?
Avatar of JHoeger
JHoeger

ASKER

Pete,
This sucka works!  Thanks so much for the help.  It is really nice of you to not only TELL me what to do, but to put in the source code is great.  No matter how smart you are, it still took time for you to carefully enter your answer, and I really appreciate it.
I made the changes to my source code in a matter of minutes.  

Thanks again, and maybe sometime I will be able to help someone else like you helped me.

JimH
Answer a question, always they will ask you again...
Teach how to and never they need to ask...
Jim,
It's my pleasure to help!

Pete
Richie,
When a question has been answered your supposed to click the 'accept as answer button'. You did give some information as to how to go about doing it, but did not post a solution. Nobody has ever taught me (from my limited experience of the IT industry you dont get taught). I'll use any available resource (whether that meens copying code from the net and pasting it straight into my app then so be it) in order to meet deadlines.
So, we need "cut & past" to be a programmer?
Never think about a solution by your own or do a research?
I DO NOT WANT to create a polemic situation, i am glad JHoeger got the solution from whoever.
I was lucky, I can interact with other people exchanging info, data and code and I am happy with that.
Anyway, This site name is Experts-Exchange, isn't it?
We don't need cut and paste, it bl**dy helps though! Go on Richie, admit it! :)
Well, one thing that we are thinking the same way
;)