Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the application I’m writing I have a ComboBox containing a selection of options available to the user. The ComboBox’s ‘DropDownStyle’ property is set to ‘DropDownList’ and I’ve created an event handler to process the SelectionChangeCommitted event.

If I display the items in the active list of the ComboBox, using either F4 or the Alt+UP or DOWN keys, choose a different option, using the UP or DOWN arrow keys, and press the TAB key then the new option is displayed in the ComboBox but the SelectionChangeCommited event is not fired off.
Posted

What's happening here is very simple:

1. When you press the 'Tab key ... and you have not defined a custom Key event handler for your ComboBox that handles the 'Tab key ... the 'Tab key does what it is supposed to do: move to the next Control/Container in the TabOrder for the Form (or the Container Control your ComboBox is in).

If you press the Return/Enter key, while moving up-and-down via arrow-keys after opening causing a DropDown via F4: you will trigger the ComboBoxes events, and get the behavior you expect.

I would strongly recommend against over-riding the behavior of the 'Tab key in any Control in Windows Forms, unless there is a very compelling reason to do so.
 
Share this answer
 
Try using the SelectedIndexChanged event from the combobox. It's a little bit unconfortable 'cause it's fired on every selection change, but you will not find yourself showing data in the rest of the controls that doesn't match the selection shown in the combobox.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900