473,729 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Synchronizing 2 grids via the CurrencyManager

I have written a custom databound grid control that we've been using
successfully for months, but one of our developers has just run into a
problem that I can't figure out.

The code for setting it up is as follows:

DataSet dataSet = new DataSet( "TestSet" );

DataTable tableParent = dataSet.Tables. Add( "TableParen t" );
tableParent.Col umns.Add( "ID", typeof( Int32 ) );
tableParent.Col umns[ "ID" ].AutoIncrement = true;
tableParent.Col umns[ "ID" ].Unique = true;
tableParent.Col umns.Add( "Col1", typeof(Int32) );
tableParent.Col umns.Add( "Col2", typeof(Int32) );

DataTable tableChild = dataSet.Tables. Add( "TableChild " );
tableChild.Colu mns.Add( "ID", typeof( Int32 ) );
tableChild.Colu mns.Add( "Col1", typeof(Int32) );
tableChild.Colu mns.Add( "Col2", typeof(Int32) );

dataSet.Relatio ns.Add( "Child2Pare nt", tableParent.Col umns[ "ID" ],
tableChild.Colu mns[ "ID" ] ).Nested = true;

gridParent.Data Source = dataSet;
gridParent.Data Member = "TableParen t";
gridChild.DataS ource = dataSet;
gridChild.DataM ember = "TableParent.Ch ild2Parent";

The way it is supposed to work (and does work with the MS DataGrid) is that
when you select a row in the parent table, it should set the data in the
child table to all children of the selected parent.

In my grid, when the current cell changes, I set the position in the
CurrencyManager to the new position. My understanding (and apparently a
false one) was that the CurrencyManager would update the position in the
underlying dataset which in turn would then inform all CurrencyManager s
bound to it. Apparently that's not the case.

The parent grid receives the CurrencyManager .PositionChange d event but the
child grid receives no events from its CurrencyManager .

How am I supposed to propagate an update to the child grid?

Thanks.

Pete
Nov 16 '05 #1
1 2051
Okay, after digging through DataGrid, BindingContext, CurrencyManager and
RelatedCurrency Manager, I have a much better idea of how it's supposed to
operate, but I still haven't solved the problem.

Both the parent and child grids are getting RelatedCurrency Manager objects
from the BindingContext because they both have DataMember set, and as far as
I can tell, this is correct. The parent grid's RelatedCurrency Manager is the
parent of the child grid's RelatedCurrency Manager.

The child RelatedCurrency Manager is subscribing to the CurrentChanged of the
parent. Now, I know the parent CurrentChanged is getting called, because I
subscribe to it in my grid.

In RelatedCurrency Manager.ParentM anager_CurrentC hanged, a call is made to
this.SetDataSou rce() which should trigger calls to ItemChanged and
PositionChanged in the child grid's RelatedCurrency Manager, which the child
grid subscribes to, but these aren't getting called.

I'm just stumped.

Pete
"Pete Davis" <pd******@NOSPA M.hotmail.com> wrote in message
news:e-*************** *****@giganews. com...
I have written a custom databound grid control that we've been using
successfully for months, but one of our developers has just run into a
problem that I can't figure out.

The code for setting it up is as follows:

DataSet dataSet = new DataSet( "TestSet" );

DataTable tableParent = dataSet.Tables. Add( "TableParen t" );
tableParent.Col umns.Add( "ID", typeof( Int32 ) );
tableParent.Col umns[ "ID" ].AutoIncrement = true;
tableParent.Col umns[ "ID" ].Unique = true;
tableParent.Col umns.Add( "Col1", typeof(Int32) );
tableParent.Col umns.Add( "Col2", typeof(Int32) );

DataTable tableChild = dataSet.Tables. Add( "TableChild " );
tableChild.Colu mns.Add( "ID", typeof( Int32 ) );
tableChild.Colu mns.Add( "Col1", typeof(Int32) );
tableChild.Colu mns.Add( "Col2", typeof(Int32) );

dataSet.Relatio ns.Add( "Child2Pare nt", tableParent.Col umns[ "ID" ],
tableChild.Colu mns[ "ID" ] ).Nested = true;

gridParent.Data Source = dataSet;
gridParent.Data Member = "TableParen t";
gridChild.DataS ource = dataSet;
gridChild.DataM ember = "TableParent.Ch ild2Parent";

The way it is supposed to work (and does work with the MS DataGrid) is that when you select a row in the parent table, it should set the data in the
child table to all children of the selected parent.

In my grid, when the current cell changes, I set the position in the
CurrencyManager to the new position. My understanding (and apparently a
false one) was that the CurrencyManager would update the position in the
underlying dataset which in turn would then inform all CurrencyManager s
bound to it. Apparently that's not the case.

The parent grid receives the CurrencyManager .PositionChange d event but the
child grid receives no events from its CurrencyManager .

How am I supposed to propagate an update to the child grid?

Thanks.

Pete

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2536
by: Keith Veleba | last post by:
Hello to all fellow c.l.p'ers! Long-time listener, first-time caller. Background: I'm working on a project where I have to do some serious multithreading. I've worked up a decorator in Python 2.3.4 to implement the lock semantics required for specific functions I want to synchronize:
0
1127
by: Bamse | last post by:
Hi, I want to synchronize (the Master-Details concept) 2 grids in 2 different forms by using BindingContext. is this possible?
1
2097
by: Kevin | last post by:
Hi Al When I have a text box, list box, and a datagrid, how does a CurrencyManager relate to all these controls(seeing as though the datagrid uses Complex binding and textbox and list box use simple bound. So for example if I have a text box, list box and a Datagrid on a windows form, and I want to navigate the records in a dataset(and we must not forget the child records from the child tables aswell!) How do I create the CurrencyManager to...
4
2812
by: Kris Bethea via DotNetMonster.com | last post by:
Greetings, I have a VB.NET program that I am trying to convert to C# (my office decided that we are going to use C# from now on). I've only been working with C# for about a month now, so this has been quite the learning experience for me. The following code is from my VB.NET program and it selects the Call Number from my datagrid and then uses that information to populate another form.
2
1505
by: orekinbck | last post by:
Hi There Using C# forms, I have a main screen that contains 2 data grids. * The data grids are connected to ArrayLists (each grid has its own ArrayList) * The data grids are intended for display purposes only * When the user clicks on a cell I want the whole row to select * The user can only select one row at a time * I want to wire up the two data grids so that changing the selected row in one data grid changes the selected row in the...
10
1879
by: D | last post by:
hi I have a form with 2 datagrids showing related table data in a master / child or order / order details type relationship. I would like to auto select the row in the order details table which contains the highest priced item. My thoughts were to get the currency manager from the orderdetails table and iterate thru each row and keep track of the highest item and row and select that when done. I have found that for some reason the...
2
3714
by: Christopher D. Wiederspan | last post by:
We are getting ready to move an ASP.NET application off of a single development machine and onto a "webfarm". Basically our webfarm is a bunch of identical servers with the load-balancing provided by a network appliance. What I'm wondering is what is the best way to keep the ASP.NET (.aspx and .dll) files synchronized across all of the servers in the farm. Our ASP.NET application is very simple - we could just copy the content to all of...
4
1649
by: Richard Fagen | last post by:
Hi, I wondering if someone can explain the best way to show three datagrids in a parent/child/grandchild relationship? For example: Take a simple form with 3 datagrids - the top for the customers, the middle for the orders, and the bottom for the items of the order. I'd like to know the best why to update the grids so that when the user
3
4409
by: Brian Richardson | last post by:
Hi, Please can anyone kindly offer some suggestions as to why the CurrencyManager might not refresh. I am using the CurrencyManager to navigate through a DataView. I am aware that there is an issue when adding a new record with using bound CheckBoxes ('http://support.microsoft.com/default.aspx?scid=kb;en-us;326440'). Due to this problem, I have decided to drop the DataBindings from my controls, clear the values, and attempt to...
0
8917
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.