How do I prevent code from executing in the SelectedValueChange event of a combobox when the combobox is being loaded for the first time? I need the code to execute when the user has selected a new value.
+2
A:
You have a few options.
Rather than letting the designer hookup the event handler you can do it yourself after loading
You can set a flag in your application for "loading" and put code inside your SelectedValueChange event to check !loading before continuing.
Personally I would just add the handler after load if it is causing issues.
Mitchel Sellers
2008-11-05 15:49:20
I just removed the handler and then hooked it up after loading
scantwell71
2009-01-16 21:57:48
+5
A:
If you only want some code to be executed when the user changes the combobox you can subscribe to SelectionChangeCommitted instead of SelectionChanged. "SelectionChangeCommitted " doesn't get called when the combobox selection is changed programmatically.
Chris Bennet
2008-12-25 14:12:06