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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Themed ComboBox Bug???

Status
Not open for further replies.

DrJavaJoe

Programmer
Oct 3, 2002
2,143
US
Start a new project and add a Combobox 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 Button1. You'll notice that the combobox's value has changed to the new value along with its list index but the SelectedIndexChanged event does not fire as would be expected upon the listindex changing, though in this case it should not have change in the first place. This occurs also in visual basic 6 but it’s the Click Event that does not fire.

To demonstrate the expected behavior comment out the line Application.EnableVisualStyles() in sub Main and try again, this time the combo's value and listindex does not change, as would be expected.

Now to take it a step further and try the same thing with any XP styled combo in windows, they all demonstrate the same behavior. This makes me wonder which of them have code in the SelectedIndexChanged event, or click event in older applications, that the developer expected to run. Where this might be a security issue is with applications that are not themed and work perfectly giving the developer a false since of security but a savvy developer decides to drop a manifest file in the executable's directory turning on the themes and thus a way around the control's SelectedIndexChanged event code.

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
MsgBox("Select Index Changed")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("Item 1")
ComboBox1.Items.Add("Item 2")
ComboBox1.Items.Add("Item 3")
ComboBox1.Items.Add("Item 4")
ComboBox1.SelectedIndex = 0
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
End Sub

Public Shared Sub Main()
Application.EnableVisualStyles() ‘comment out to turn off themes
Application.Run(New Form1)
End Sub

I did start this in the VB6 forum but thought it should be here also.


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