VB.Net Custom Object Master-Detail Data Binding

Posted by clawson on Stack Overflow See other posts from Stack Overflow or by clawson
Published on 2010-03-08T13:23:18Z Indexed on 2010/03/08 13:36 UTC
Read the original article Hit count: 484

Filed under:
|
|

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:

  1. 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.

  2. Is this approach to DataBinding good/viable.

  3. What's the best way to separate business logic from graphical interface.

Thanks for the help!

© Stack Overflow or respective owner

Related posts about databinding

Related posts about vb.net