Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox Bug???

Status
Not open for further replies.

DrJavaJoe

Programmer
Oct 3, 2002
2,143
0
0
US
Start a new project and add a Combobox setting its style property to 2 - Dropdown List and a command button. Then add the following code and run the app. Now click on the drop down arrow and mouse over item 2, 3 or 4 in the drop down list, as you mouseover each item it should become highlighted. Now rather than clicking on one of the items just press the tab key to change focus to command1. You'll notice that the combobox's value has changed to the new value along with its list index but the click event does not fire. I am of the opinion that the expected behavior of a combobox with the style property set to 2 - Dropdown List, should fire the click event when the value or listindex is changed.

Option Explicit

Private Sub Combo1_Click()
MsgBox "clicked"
End Sub

Private Sub Command1_Click()
MsgBox Combo1.ListIndex
End Sub

Private Sub Form_Load()
Combo1.AddItem "Item 1"
Combo1.AddItem "Item 2"
Combo1.AddItem "Item 3"
Combo1.AddItem "Item 4"
Combo1.ListIndex = 0
End Sub



Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
>You'll notice that the combobox's value has changed to the new value along with its list index

Interesting: I don't see that behaviour...

>I am of the opinion that the expected behavior of a combobox

I am of the opinion that the expected behaviour is that tabbing focus away shouldn't cause the value to change (and, as I mentioned above, it doesn't on the PC I'm currently working on)
 
I don't see that behaviour either ...
 
Ok I just tested this on three XP machines and they all are experiencing this behavior. I tested it on an NT 4 box and it doesn't. I just noticed that I do not have to be in Visual Basic for the behavior to occur, if I drop down the address combo in Internet Explorer it does the same but the combo .net does not. I'm going into a meeting at the moment but when I get out I will grab my laptop from the car which has XP and is not part of this domain and see if it maybe a AD problem or setting.

strongm, I agree completely with your second point, that is exectly the behavior I would expect.


Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
I found the pattern it only occurs in XP themed combos such as Internet Explorer's or in my case I themed Visual Basics IDE.


Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
Aha! So, another bug in theming ...
 
Yeah, just look around your desktop at all of the XP styled combos and wonder which of them have code in the click event that the developer expected to run.


Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top