>Table_A Table_B Table_C >ID_A 1-------+ ID_B 1--------+ ID_C >GroupName | SubGroupName | ProductName > +----N ID_A +---N ID_B >>
>Table_A Table_C
>ID_A 1-------+---+ ID_C
>GroupName | | ProductName
>ID_A_Main N--+ +---N ID_A
>
>Select ; Padr(Padl(1,3,'_')+cust_id,20) As nodekey,; Space(20) As parentkey,; Padr(Company,100) As NodeText ; from (_samples+"data\customer") ; into Cursor crsTree ; readwrite Insert Into crsTree (nodekey,parentkey,NodeText) ; Select ; padl(2,3,'_')+order_id As nodekey,; padl(1,3,'_')+cust_id As parentkey,; Textmerge('[<<order_id>>] <<order_date>>') As NodeText ; from (_samples+"data\orders") Insert Into crsTree (nodekey,parentkey,NodeText) ; Select ; padl(3,3,'_')+order_id+padl(line_no,3,'_') As nodekey,; padl(2,3,'_')+order_id As parentkey,; '['+oi.order_id+'] item:['+Transform(oi.line_no)+'] '+pr.prod_name As NodeText ; from (_samples+"data\orditems") oi ; inner Join (_samples+"data\products") pr On oi.product_id = pr.product_id ; order By order_id,line_no #Define tvwFirst 0 #Define tvwChild 4 Public oForm oForm = Createobject('myForm') oForm.Show Define Class myForm As Form Height = 600 Width = 600 DoCreate = .T. Caption = "TreeView sample" Add Object myTree As OleControl With ; Height = 600, ; Width = 600, ; OleClass = 'MSComCtlLib.TreeCtrl' *-- Fill the tree values Procedure filltree Select crsTree With This.myTree.nodes Scan If Empty(parentkey) .Add(,tvwFirst,nodekey,NodeText) Else .Add(parentkey, tvwChild, nodekey, NodeText ) Endif Endscan Endwith Endproc Procedure Init With This.myTree .linestyle =1 .labeledit =1 .indentation = 5 .Scroll = .T. Endwith This.filltree() Endproc EnddefinePS: Also check UT magazine June 2001 issue.