Since beginning to use VB.NET some years ago I have become slowly familiar with using the data binding features of .NET, however I often find my self bewildered by it's behavior and instead of discover the correct way it should work I find some dirty work around to suit my needs and continue on.
Needless to say my problems continue to arise.
I am using Custom Objects as the Data Sources for by controls and often entire forms. I find it frustrating to separate business logic and the graphical interface. (That could be a new question entirely.) So for a lot of objects I generate a form which has the DataBindingSource
for the object. When I create each from using the New Constructor I explicitly pass to it the object to which it should be bound, and then set this passed object as the DataSource
of the BindingSource
. (That's a mouthful!)
Now the Master object (say, bound to each form) often contains a List of objects which I like to have displayed in a DataGridView
. I (sometimes) create and modify these child objects in their own form (again creating a databind the same way as the master form) but when I add them to the List in the master object the DataGridView
won't update with the new items.
So my question really has a few layers:
How can I easily/efficiently/correctly update this
DataGridView
with the list of Detail objects when I add them to the list of the Master object.Is this approach to
DataBinding
good/viable.What's the best way to separate business logic from graphical interface.