mwe
Joined: 08 Dec 2005 Posts: 15
|
Posted: Sun Dec 11, 2005 5:58 pm Post subject: Trees and Dataset |
|
|
A typical way to represent a tree in a DataSet is to have a Table with for example the following columns;
Id (PK)
ParentId (FK)
Name
and a relation connecting the FK with the PK.
Code: |
dataset.Tables["Items"].Rows.Add(new object[] { 1, null, "One" });
dataset.Tables["Items"].Rows.Add(new object[] { 2, 1, "Two" });
dataset.Tables["Items"].Rows.Add(new object[] { 3, 1, "Three" });
dataset.Tables["Items"].Rows.Add(new object[] { 4, 2, "Four" });
|
This would represent the tree
Code: |
One-+-Two-Four
|
+-Three
|
Now using VirtualTree and data binding works kind of. If you point VirtualTree to the dataset and point it to the table it will use the relationship defined for both parent and child relationship. It will then display the tree I expect but also every possible subtree which is not what I want.
Does any one have a soloution to this problem or is the answer as I suspect, don't use data binding do it the hard way i.e. I have to populate the tree myself. _________________ Kind regards
Magnus Werner, System Architect
------------------------------------------
Saab Training Systems AB |
|