BindingSource and currency management event question...

  • Thread starter Thread starter Jamie Risk
  • Start date Start date
J

Jamie Risk

I have several 'generations' of parent-child DataTable
relations in my code, and was wondering how best to improve
(fix) the following.

When navigating through a parent table, I wan't to automatically
update the child tables filters and displays. I've done this
through the DataTable's BindingSource.CurrencyManager
PositionChanged event. Within the event handler, I call out to
child table delegate and to do the following.

this.bindingSource.Filter = string.Format("{0} = {1}",
idParentColumnName, idParentValue);
this.bindingSource.MoveLast();
this.bindingSource.MoveFirst();

I have found however, that in order to propogate the filter
updates through several 'generations' of parent-child relations,
I need to call to programmatically change the position being
displayed. Unless there is only one record in the DataTable,
this code succesfully triggers the PositionChange event for
child table.

Is there a more clever way of doing this?

- Jamie
 
If the tables have a parent-child relationship established with a foreign key
modeled in a single DataSet then there is no need for filters. Merely create
another BindingSource as set the DataSource to the parent's BindingSource and
the DataMember to the foreign key.

' Parent BindingSource
With bsComp
.DataSource = aideDS
.DataMember = "tblPprComponents"
End With

' Child BindingSource
With bsCompLinks
.DataSource = bsComp
.DataMember = "FK_tblPprComponents_tblPpr_PprComp_Links"
End With
 
Back
Top