2

I know this question exists but I can't find the solution in the answers.

I have a form with a data-binding to a custom class so that when changing the form, the custom class gets notified (the inverse will never happen).

myForm.DataBindings.Add("Items", ItemsController.Singleton, "Items", false, DataSourceUpdateMode.OnPropertyChanged); 

What is happening now is that when I create an instance of the form and set the Items property with some values, the data-binding checks for the ItemsController Items property and updates it back to the form with 0 Items, I want to prevent that using a one-way data-binding.

Is it possible or I will have to rely on event's only?

6
  • In DataBinding "OneWay" mean update direction only from DataSource to Form control. Commented Aug 24, 2016 at 17:46
  • From Form control to custom Class Commented Aug 24, 2016 at 17:46
  • Why you cannot set the items to the custom class Items property, then it is works. And remember to implements INotifyPropertyChanged interface in your Custom class Commented Aug 24, 2016 at 17:48
  • Let me see. You want setting the form Items property to update the ItemsController, but not the opposite? Commented Aug 24, 2016 at 17:52
  • @Fabio that's one option, but since I used a Factory pattern to create the Form I wanted the factory to handle the binding between the two (thank you for trying to help, I just want to learn and I don't understand the downvotes :/) Commented Aug 25, 2016 at 0:04

1 Answer 1

6

Looks like you are seeking for Binding.ControlUpdateMode property:

Gets or sets when changes to the data source are propagated to the bound control property

myForm.DataBindings.Add(new Binding("Items", ItemsController.Singleton, "Items") { DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged, ControlUpdateMode = ControlUpdateMode.Never }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.