Monthly Archives: April 2012

Remember to use correct event handler for combobox user changes

I always forget to select the correct event handler when wiring up comboboxes, I think mainly due to the fact that the default handler selected for you by Visual Studio always tends to be SelectedIndexChanged.

You should always use SelectionChangeCommitted if you want to capture user changes for comboboxes – indeed the Microsoft MSDN docs tell you this too – so no real excuses here!

SelectionChangeCommitted is raised only when the user changes the combo box selection. Do not use SelectedIndexChanged or SelectedValueChanged to capture user changes, because those events are also raised when the selection changes programmatically.

You can create a SelectionChangeCommitted event handler to provide special handling for the ComboBox when the user changes the selected item in the list.


Get Temp Directory

Just a little snippet – it’s useful to know and I always forget what the exact syntax is so…..


Will return you something similar to:

C:\Documents and Settings\foousername\Local Settings\Temp\