Home > database >  NotifyPropertyChanged not changing my control when I Instanciate a new Source
NotifyPropertyChanged not changing my control when I Instanciate a new Source

Time:08-31

I'm new to WinForms. I'm trying to make a simple binding to my control:

numQuality.DataBindings.Add("Text", Config.Workspace.GenerationSetup, dataMember: "DdimSteps", false, DataSourceUpdateMode.OnPropertyChanged);

In resume, it's a numeric box that I binded to a configuration property, if I change the DdimSteps, the textbox changes as well.

The problem is when I need to Instantiate a new Config.Workspace, it don't refresh the textbox.

I have tried to implement the INotifyPropertyChanged and call the PropertyChanged when the Config.Workspace is changed. But even though the method is being called, NumericBox does not updates.

CodePudding user response:

You need to setup a BindingSource with DataSource set to Config.Workspace.GenerationSetup then you will bind textbox to that BindingSource instead. then if you want to change objet, set DataSource property of DataBindingSource

  • Related