Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Using a BindingSource with control valuechanged events
 

Using a BindingSource with control valuechanged events

I am using a binding source to update data to some controls (textboxes, comboboxes). My DataSourceUpdateMode is set to OnPropertyChanged. I have ValueChanged events on all my controls. Whenever I change data for one control, all the controls bound to the binding source get the value changed event. Is there some way to only get value changed events for the control that was edited or maybe some way to tell if the binding source caused value changed or a user actually changed data? Thanks

mlde  Thursday, August 06, 2009 7:00 PM
> the controls bound to the binding source get the value changed event

Ouch. What kind of controls are these? It would seem that the Value properties of these controls do not check that the value was actually modified. If these are controls developed by you, consider revising the Value setter so that the event is only raised if the new value for the backing field differs from the old value.

If you cannot modify the controls, then you'll need to keep track of the old values on the side and do the comparison yourself in the event handler to detect the spurious events.


BinaryCoder  Thursday, August 06, 2009 11:40 PM
Hi mlde,

When you bind some controls with the same object, you will be notified when the property value is changed. That cannot be apply to part of these controls but to all. If you don't want some control receive the change, you'd better do not use binding for these control.

The function of binding is to keep all the controls bind to the same source get data changed synchronously.

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Monday, August 10, 2009 3:33 AM
We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Thursday, August 13, 2009 7:02 AM

You can use google to search for other answers

Custom Search

More Threads

• Assign a selected value to a combo box
• HELP for my ICT coursework
• BindingSource.EndEdit vs DataTable.AcceptChanges
• DataGridView cell value change/update triggered from a graphing control via mouse click?
• Saving Dataset Creates Duplicate Desginer.vb File
• Typed DataSet and WriteXml question about Namespace
• Datagridview Celltype: set at runtime; How set of hosted custom control in property grid
• DataGrid - highlight whole row on click? (.NET 1.1)
• How does one bind to a multiple selection ?
• How can I Write MCAD Exam?