Databinding in combobox?

You need change the property of binding which describes when to update the backend object from lost focus to value changed.

Up vote 0 down vote favorite share g+ share fb share tw.

Reference: C# databinding on combobox I have a similar situation. I have a form with few text boxes, combo boxes, check boxes. Initially I use to catch "changed" event (like, text_changed, selected_index_changed.

Etc) and sync the UI data with a backing object. I learned about Databinding and I bound all the UI elements to my backing object. Problem: Based upon state of my UI, I was enabling and disabling "Submit" button which uses backing object to save to contents.

But now, due to DataBinding, property of backing object does not change unless the control bound to that properly looses focus. Question Is there a standard way to solve this problem? Or do I still need to catch "changed" event and set the value of backing object?

Also, to make the form fault tolerant, I use to save the backing object every N seconds. But with DataBinding (given that the control which is on focus still havn't set its value to the backing object) I will be saving wrong data. What I tried Evey N seconds call this.validate() -> this does not work as it actually populate the old data in the control on focus.

----- NOTE ------ The backing object implements INotifyPropertyChanged interface. And this is how I bind (not in designer) but in code. Binding binding = new Binding("checked", solution, "InternalFlag"); checkBoxFlag.DataBindings.

Add(binding); c# 2-way-object-databinding link|improve this question edited Oct 11 '11 at 17:55 asked Oct 11 '11 at 17:48karephul1518 52% accept rate.

You need change the property of binding which describes when to update the backend object from lost focus to value changed Data Source Update Mode binding = new Binding("checked", solution, "InternalFlag", true, System.Windows.Forms. DataSourceUpdateMode. OnPropertyChanged)).

I tried to quickly find it, but I was unable to. – karephul Oct 11 '11 at 18:09 I have already tried setting "binding. DataSourceUpdateMode = DataSourceUpdateMode.

OnPropertyChanged" but that doesn't work either – karephul Oct 11 '11 at 18:12 Are you sure? Because your code doesn't specify it – Haris Hasan Oct 11 '11 at 18:18 I was setting it like .... this.checkBoxFlag.DataBindings. DefaultDataSourceUpdateMode = DataSourceUpdateMode.

OnPropertyChanged; – karephul Oct 11 '11 at 18:24 But I noticed that if I set the DataSourceUpdateMode directly on the Binding object, it works .. – karephul Oct 11 '11 at 18:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions