Multiple DataRelations and DataGrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to accomplish a DataRelation not only between Parent and Child but
also to a Grandparent.

I thought that would be possible by establishing a Datarelation between
GrandParent and Parent and another one between Parent and Child. Here is part
of the code:

// Fill the dataSet1 with the three tabels Grand, Parent and Child, and then:

DataColumn ColumnGrandIdA;
DataColumn ColumnParentIdA;
DataColumn ColumnParentIdB;
DataColumn ColumnChildIdB;

DataRelation RelationGrandParent;
DataRelation RelationParentChild;

ColumnGrandId = dataSet1.Tables["Grand"].Columns["IdA"];
ColumnParentIdA = dataSet1.Tables["Parent"].Columns["IdA"];
ColumnParentIdB = dataSet1.Tables["Parent"].Columns["IdB"];
ColumnChildIdB = dataSet1.Tables["Child"].Columns["IdB"];
RelationGrandParent = new DataRelation("RelationGrandParent",
ColumnGrandIdA, ColumnParentIdA);
RelationParentChild = new DataRelation("RelationParentChild",
ColumnParentIdB, ColumnChildIdB);
dataSet1.Relations.Add(RelationGrandParent );
dataSet1.Relations.Add(RelationParentChild );
dataGrid1.SetDataBinding(dataSet1, "Grand");
dataGrid2.SetDataBinding(dataSet1, "Grand.RelationGrandParent");
dataGrid3.SetDataBinding(dataSet1, "Parent.RelationParentChild");

Now only the dataGrid2 binding works. If I comment out the line
dataGrid2.SetDataBinding the dataGrid3 binding works.

How do I make the two bindings work simultaneously?

Örjan Leringe
 
This is to clarify better what I think is not working as it should: When I
navigate in the first grid(Grand) the second grid displays the parents in the
second grid. The childs to the parents are there if I expand the rows in the
second grid. BUT: I want the children to turn up automatically iin the third
grid also!

How can I do this? I have had no problem doing this in Borland JBuilder
using their very similar DataExpress class libriaries in Java.

Örjan
 
Back
Top