I have a list of classes that represent mydatabase tables for example Address,Client.
My GUI tends to be a grid of data and an data entry form. This works fine for single table data entry however I now have a form that has client information and their address.
I was thinking of using a ViewModel combining the Address and Client class and assigning that to a bindingsource and binding my controls to that.
How would I bind the controls to the property names? Would this work…
if (txtLine1.DataBindings.Count == 0)
txtLine1.DataBindings.Add("Text", bindingSource, "Address.Line1", false, DataSourceUpdateMode.OnPropertyChanged);
Is having a ViewModel even possible for Winforms databinding?
I created a ViewModel and then created a DataSource in VS. I then dragged the properties of the classes in my viewmodel to the form and this created the controls I needed. I then call the Save method for each class in my viewmodel.