Same bindingsource between two forms: good practice?

Robert_SF

Active member
Joined
Apr 2, 2011
Messages
30
Programming Experience
Beginner
The MSDN documentation explains that you can use the same bindingsource between two forms, so that changes made on one form automatically reflect on the second. The procedure is explained here:
How to: Share Bound Data Across Forms Using the BindingSource Component

However, doesn't this create too much dependency between two forms?

For example, an Add Customer form that has its own bindingsource (and tableadapter) can be called from anywhere, and it will do its job. But if you change this form to receive a bindingsource in its constructor, now it can only be called from a place that can provide a bindingsource.

What do you see as the pro and cons of this approach?
 
More flexible than having it receive a CustomerDataTable, and you wouldnt have it receive a TableAdapter(because theyre type specific with no common parent), or contain one (because then it can only work with datatables anyway)

Passing it a BS means you can base your BS on another kind of data source (not just a datatable) and it will still work and perform the ultimate goal of the Customer form; to manipualte the data that it is passed
 
More flexible than having it receive a CustomerDataTable, and you wouldnt have it receive a TableAdapter(because theyre type specific with no common parent), or contain one (because then it can only work with datatables anyway). Passing it a BS means you can base your BS on another kind of data source (not just a datatable) and it will still work and perform the ultimate goal of the Customer form; to manipualte the data that it is passed

Oh, I see. My Add Customer form did contain its own DataSource, TableAdapter, and BindingSource before I set it up to receive a BS. I thought that made the form completely self-contained from its functional point of view. But I know I'm mentally stuck in the old structured style of coding, and I need to wrap my head around OO.

Btw, I read your posts on parameter queries and found them really helpful. I no longer build queries by painfully stitching strings together. It was such a hassle but I didn't really know any other way. :)
 
Back
Top