> > oNode = thisform.treeview.nodes.add(.... > > ADDPROPERTY(oNode, cPropertyName, ePropertyValue) > >>
oForm = NEWOBJECT([Form1]) oForm.Show(1) ************************************************** *-- Form: form1 (d:\test\test.scx) *-- ParentClass: form *-- BaseClass: form *-- Time Stamp: 11/14/07 09:28:04 PM * DEFINE CLASS form1 AS form Top = 0 Left = 0 Height = 253 Width = 475 DoCreate = .T. Caption = "Form1" mynodeproperties = .F. Name = "Form1" ADD OBJECT oletree AS olecontrol WITH ; Top = 1, ; Left = 24, ; Height = 240, ; Width = 334, ; Name = "oleTree",; oleClass=[MSComctlLib.TreeCtrl.2] ADD OBJECT text1 AS textbox WITH ; Height = 23, ; Left = 370, ; Top = 4, ; Width = 100, ; Name = "Text1" ADD OBJECT text2 AS textbox WITH ; Height = 23, ; Left = 370, ; Top = 37, ; Width = 100, ; Name = "Text2" ADD OBJECT text3 AS textbox WITH ; Height = 23, ; Left = 370, ; Top = 67, ; Width = 100, ; Name = "Text3" PROCEDURE filltree LPARAMETERS lnParentKey LOCAL lnRecNo, oEmpty AS EMPTY oEmpty = NEWOBJECT([EMPTY]) ADDPROPERTY(oEmpty,[NodeText] ,[]) ADDPROPERTY(oEmpty,[NodeKey] ,0) ADDPROPERTY(oEmpty,[Something] ,[]) IF VARTYPE(lnParentKey) == [L] thisform.myNodeProperties = NEWOBJECT([Collection]) SEEK 0 IN crsTest SCAN WHILE Parent = 0 lnRecNo = RECNO() thisform.oleTree.Nodes.Add(,1,TRANSFORM(Key)+[_],Text) ADDPROPERTY(thisform.oleTree.Nodes(TRANSFORM(Key)+[_]),[NodeText],Text) thisform.FillTree(Key) GOTO lnRecNo ENDSCAN ELSE SEEK lnParentKey IN crsTest SCAN WHILE Parent = lnParentKey lnRecNo = RECNO() oNode = thisform.oleTree.Nodes.Add(TRANSFORM(Parent)+[_],4,TRANSFORM(Key)+[_],Text) ADDPROPERTY(thisform.oleTree.Nodes(TRANSFORM(Key)+[_]),[NodeText],Text) thisform.FillTree(Key) GOTO lnRecNo ENDSCAN ENDIF ENDPROC PROCEDURE Load CREATE CURSOR crsTest (Key I, Parent I, Text varchar(100)) INSERT INTO crsTest VALUES(1,0, 'root text') INSERT INTO crsTest VALUES(2,1, 'child text 1') INSERT INTO crsTest VALUES(3,1, 'child text 2') INSERT INTO crsTest VALUES(4,2, 'grandchild text 1') INDEX ON Parent TAG crsTest ENDPROC PROCEDURE Init thisform.FillTree() ENDPROC PROCEDURE oletree.NodeClick *** ActiveX Control Event *** LPARAMETERS node ******* BOOOM ****** thisform.Text1.Value = node.NodeText ENDPROC ENDDEFINE * *-- EndDefine: form1 **************************************************