PUBLIC oform1 oform1=NEWOBJECT("form1") oform1.Show RETURN ************************************************** *-- Form: form1 (c:\testtree.scx) *-- ParentClass: form *-- BaseClass: form *-- Time Stamp: 07/27/05 11:37:02 AM * DEFINE CLASS form1 AS form Top = 0 Left = 0 Height = 448 Width = 382 DoCreate = .T. Caption = "Form1" *-- XML Metadata for customizable properties _memberdata = "" Name = "Form1" ADD OBJECT oletree AS olecontrol WITH ; Top = 24, ; Left = 20, ; Height = 341, ; Width = 335, ; Name = "oleTree" ADD OBJECT command1 AS commandbutton WITH ; Top = 394, ; Left = 23, ; Height = 27, ; Width = 181, ; Caption = "Move Selected Node Up", ; Name = "Command1" ADD OBJECT text1 AS textbox WITH ; Height = 23, ; Left = 220, ; ReadOnly = .T., ; Top = 396, ; Width = 137, ; Name = "Text1" PROCEDURE oletree.NodeClick *** ActiveX Control Event *** LPARAMETERS node thisform.command1.Refresh() thisform.Text1.Refresh() ENDPROC PROCEDURE oletree.Init local loNode with this.Nodes .Add(,, 'Root', 'Root Node') .Add('Root', 4, 'Child1', 'First Child') .Add('Root', 4, 'Child2', 'Second Child') .Add('Root', 4, 'Child3', 'Third Child') .Add('Child1', 4, 'GrandChild1', 'First GrandChild') .Add('Child1', 4, 'GrandChild2', 'Second GrandChild') .Add('Child2', 4, 'GrandChild3', 'Third GrandChild') .Add('Child2', 4, 'GrandChild4', 'Fourth GrandChild') .Add('Child3', 4, 'GrandChild5', 'Fifth GrandChild') .Add('Child3', 4, 'GrandChild6', 'Sixth GrandChild') .Add('Child3', 4, 'GrandChild7', 'Seventh GrandChild') .Add('Child3', 4, 'GrandChild8', 'Eigth GrandChild') .Add('Child3', 4, 'GrandChild9', 'Nineth GrandChild') .Add('Child3', 4, 'GrandChild10', 'Tenth GrandChild') .Add('Child3', 4, 'GrandChild11', 'Eleventh GrandChild') .Add('Child3', 4, 'GrandChild12', 'Twelveth GrandChild') endwith for each loNode in this.Nodes loNode.Expanded = .t. endfor ENDPROC PROCEDURE command1.Click local loNodeToMove, loNextNode, loPrevious, loNodes, loParent, loNode loNodeToMove = thisform.oleTree.SelectedItem loPrevious = loNodeToMove.Previous loParent = loNodeToMove.Parent if not Isnull(loPrevious) loNodes = Createobject('Collection') do while not Isnull(loPrevious.Previous) with loNodes as Collection .Add(loPrevious.Previous) loPrevious = loPrevious.Previous endwith enddo loNodeToMove.Parent = loParent for each loNode in loNodes loNode.Parent = loParent endfor endif ENDPROC PROCEDURE command1.Refresh this.enabled = not Isnull(thisform.oleTree.SelectedItem) and thisform.oleTree.SelectedItem.Key # 'Root' ENDPROC PROCEDURE text1.Refresh this.Value = Iif(Isnull(thisform.oleTree.SelectedItem), .null., thisform.oleTree.SelectedItem.Key + ' (' + Transform(thisform.oleTree.SelectedItem.Index) + ')') ENDPROC ENDDEFINE * *-- EndDefine: form1 **************************************************