Combo Boxes in VB.NET (Visual Studio)

dpatfield66

Well-known member
Joined
Apr 6, 2006
Messages
136
Programming Experience
5-10
I have all my combo boxes set to drop down on GotFocus.
This is good when the user tabs from control to control.

But for some reason, when I select a combobox pulldown arrow (unless I'm already in it), the dropdown occurs and then disappears, and then I have to select the combo box AGAIN to get the drowpdown to appear.

Also, if I am in a box with a drop down, for some reason I have to click again to get the focus of the text, perhaps? and THEN I can click into another control...pretty aggravating.

What I want: User clicks "down-arrow" and the dropdown list drops down.
User can select another control without having to double-click (what the heck IS that??)

Anyone know about this??
 
you could probably use a boolean variable to determin if the control got focus because of tabbing or by clicking on it with the mouse

i'll play with it sometime and see what's up
 
You might have something there...

Do you know off the bat, how to determine if user got focus due to tab versus click? I don't know the code for that.
 
the form's keydown event catches tab keys, all you would have to do is flag it when the tab key is pressed, then of course check it when the cbo box get's focus

then again combobox's do have a click event too, which is fired when the mouse clicks on it, thus it's an event that's not fired due to the tab key being pressed
 
Thanks...this part I know and understand.
Here's my question:
==================================
If <got focus was based on tab> Then
sender.droppeddown = True
ElseIf <got focus was based on click> Then
(Well, actually I want the dropdown to occur for both.)
End If
================================

What I really want to NOT happen is...

When user clicks on a cbo, the dropdown flashes and then it's gone.
The SECOND time they click, THEN the dropdown stays dropped.

If they tab to the control, the dropdown works normally (i.e.: stays down).

This only occurs when I have "sender.droppeddown = True" on GotFocus Event. I set the event to Click rather than GotFocus, and the flash is gone, but they can't tab to the control and have it drop down.

But I don't want to say droppeddown = False for a click. I WANT the dropdown to occur! So, I'm not sure what to do here. Or DO I. Maybe I only want the dropdown to occur on either Click Event or Got Focus (tabbing only)

That way if they click it works normally, if they tab in, it works normally, but it doesn't work on GotFocus (except for Tab)

In ANY case, I'm still curious as to how to code this:

<Got focus was based on Tab> or <Got Focus was based on click>

It has something to do with KeyDown or KeyCharacter, or something like that, correct?

If keypress = <tab> or whatever...this is what I'm trying to figure out.
In addition to my click, tab dilemma, of course.

Just to simplify everything I previously wrote.

I am using a Click Event currently, with <sender.droppeddown = True>

I WAS using a GotFocus Event, but when a user clicked into the field, or clicked the arrow button, the dropdown would flash once and disappear. They could then click again and get it to stay.

So, do you think I should keep the click event, because the flasing dropdown does not occur with this.

And ALSO have a GotFocus Event that only dropsdown on a tab into the field?

Lastly, if I DO use the GotFocus tab only, how would I code this?

If <what do I put here....keydown = blah blah, or something like that?>

There IS one similar issue:

No matter what I use, if a dropdown occurs and stays, the user has to click again to remove the dropdown. Whether it's by selecting a value or just clicking the mouse. Either way, the focus goes to the textbox associated with the dropdown.

This sucks. In other words. If I select a field with dropdown, it drops down the lookup values, but if I decide to click on any other field, I don't automatically go to that other field, but rather the focus goes to the textbox portion of the combobox I'm still in. It's almost like a doubleclick.

I understand it myself, but users might get confused.

Finally, as long as we're talking about comboboxes.
How do I make a combobox read only, rather than disabled.
So that the text is not greyed out, but the user can't select a value, nor can they type a value in?

I saw some code for C++, but couldn't equate it to VB.Net
 
Back
Top