krypto2000
asked on
treeView from dataSet
Hello,
I want to make a treeView from a dataSet
this is my values :
-------------------------- ---------- ----
| wks_desc | sct_desc | type_desc |
-------------------------- ---------- ----
|Emboitage | stk | montres |
|Emboitage | ipg | montres |
|Certissage | stk | montres |
|Certissage | stk | plaques |
|Certissage | ipg | montres |
|Certissage | ipg | plaques |
-------------------------- ---------- ---- okay....
with these data, i want to have a treevView like this
+ Workshop
+ ---Emboitage
+ ---stk
|---montres
+ ---ipg
|---montres
+ ---Certissage
+ ---stk
|---montres
|---plaques
+ --- ipg
|---montres
|---plaques
that's all !! please help !!! :-O
I want to make a treeView from a dataSet
this is my values :
--------------------------
| wks_desc | sct_desc | type_desc |
--------------------------
|Emboitage | stk | montres |
|Emboitage | ipg | montres |
|Certissage | stk | montres |
|Certissage | stk | plaques |
|Certissage | ipg | montres |
|Certissage | ipg | plaques |
--------------------------
with these data, i want to have a treevView like this
+ Workshop
+ ---Emboitage
+ ---stk
|---montres
+ ---ipg
|---montres
+ ---Certissage
+ ---stk
|---montres
|---plaques
+ --- ipg
|---montres
|---plaques
that's all !! please help !!! :-O
Google TVirtualTreeview...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
okay that's grate it work !!
i don't understant your logic so if you wan't you can explain me it would be good but i you don't wan't no problem...
thanks !
i don't understant your logic so if you wan't you can explain me it would be good but i you don't wan't no problem...
thanks !
This was fairly easy for one main reason : the level of indentation of the items in the TreeView is known in advance ('wks_desc' is always at level 0, 'sct_desc' at level 1, ...)
Here we go for the details :
- when I call AddNode for the level 0, it doesn't have a parent (top level nodes don't), so I set nodParent to nil.
- I search through the TreeView to see if a node with same parent already exists or not. If it doesn't, I create it.
- in any case I return this node (existing or just created) so that the next level item knows who is it's parent.
- and for the last level, I ignore the return result because there are no more levels.
Writing that gave me the idea of better version of the same code, which will work with any number of fields :
while not ADODataSet1.Eof do
begin
nodNext:=nil;
for iChamps := 0 to ADODataSet1.FieldCount-1
do nodNext:=AddNode(nodNext,A DODataSet1 .Fields[iC hamps].Tex t);
ADODataSet1.Next;
end;
Just make sure that in the query the fields are in the right order !
Cheers,
David
Here we go for the details :
- when I call AddNode for the level 0, it doesn't have a parent (top level nodes don't), so I set nodParent to nil.
- I search through the TreeView to see if a node with same parent already exists or not. If it doesn't, I create it.
- in any case I return this node (existing or just created) so that the next level item knows who is it's parent.
- and for the last level, I ignore the return result because there are no more levels.
Writing that gave me the idea of better version of the same code, which will work with any number of fields :
while not ADODataSet1.Eof do
begin
nodNext:=nil;
for iChamps := 0 to ADODataSet1.FieldCount-1
do nodNext:=AddNode(nodNext,A
ADODataSet1.Next;
end;
Just make sure that in the query the fields are in the right order !
Cheers,
David
ASKER
Okay thank you that's very good !!!
I had a completely different approach, I had almost arrived there but it was surely not the maid ;-)
regards,
Matthias
I had a completely different approach, I had almost arrived there but it was surely not the maid ;-)
regards,
Matthias