Hello
I'm trying to load a treeview with data from a sqlite table. The table contains heirarchial data using the adjacency model.
For example, if the table contained an organisational structure it would be as follows.
tblEmployees
Col1: EmployeeName
Col2: Boss
EmployeeName___Boss
Matt_____________<Null>
Dave_____________Rachael
Sue______________Matt
Carl______________Tim
Tim______________Matt
Rachael___________Matt
Peter_____________Tim
Paul______________Peter
Ian_______________Peter
In the treeview, this would be displayed as follows
+Matt
___+Sue
___+Tim
______+Carl
______+Peter
_________+Ian
_________+Paul
___+Rachael
______+Dave
I have done this in vb6 before using a recursive procedure call, i.e. You first find the parent record (the one with a null boss) and add it to the treeview, you then filter all records that have that boss and add them to the treeview. After adding each node, you recall the prodedure passing the current employee as the filter (boss) for the next level in the treeview.
My problem is that I cannot see how I can pass the current node within the recursive sub so the employees go under the correct branch of the tree.
Many thanks
tinfoil
I'm trying to load a treeview with data from a sqlite table. The table contains heirarchial data using the adjacency model.
For example, if the table contained an organisational structure it would be as follows.
tblEmployees
Col1: EmployeeName
Col2: Boss
EmployeeName___Boss
Matt_____________<Null>
Dave_____________Rachael
Sue______________Matt
Carl______________Tim
Tim______________Matt
Rachael___________Matt
Peter_____________Tim
Paul______________Peter
Ian_______________Peter
In the treeview, this would be displayed as follows
+Matt
___+Sue
___+Tim
______+Carl
______+Peter
_________+Ian
_________+Paul
___+Rachael
______+Dave
I have done this in vb6 before using a recursive procedure call, i.e. You first find the parent record (the one with a null boss) and add it to the treeview, you then filter all records that have that boss and add them to the treeview. After adding each node, you recall the prodedure passing the current employee as the filter (boss) for the next level in the treeview.
My problem is that I cannot see how I can pass the current node within the recursive sub so the employees go under the correct branch of the tree.
Many thanks
tinfoil
Last edited: