HighTechTalks DotNet Forums  

BindingSource and currency management event question...

Dotnet Framework microsoft.public.dotnet.framework


Discuss BindingSource and currency management event question... in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jamie Risk
 
Posts: n/a

Default BindingSource and currency management event question... - 07-25-2007 , 01:36 PM






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

Reply With Quote
  #2  
Old   
Rick Mogstad
 
Posts: n/a

Default Re: BindingSource and currency management event question... - 08-15-2007 , 01:46 PM






Using the CurrentChanged event.


"Jamie Risk" <risk.#. (AT) intectus (DOT) com> wrote

Quote:
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



Reply With Quote
  #3  
Old   
SteveKing
 
Posts: n/a

Default RE: BindingSource and currency management event question... - 10-10-2007 , 10:35 AM



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

"Jamie Risk" wrote:

Quote:
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


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.