* Form.Filltree - fills the nodes from a cursor/table * Define some constants. #Define tvwFirst 0 #Define tvwLast 1 #Define tvwNext 2 #Define tvwPrevious 3 #Define tvwChild 4 With This.OleTree .linestyle =1 .labeledit =1 .indentation = 5 .PathSeparator = '\' .Scroll = .T. .OLEDragMode = 0 .OLEDropMode = 0 .CheckBoxes = .F. Endwith Select * ; from myCursor ; order By Level,Item ; into Cursor crsItems ; nofilter Local oNode With This.OleTree.nodes Scan If crsItems.Level = 0 .Add(,tvwFirst,; Trim(crsItems.NodeID),; Trim(crsItems.NodeText)) Else .Add(Trim(crsItems.ParentID), tvwChild, ; Trim(crsItems.NodeID), ; Trim(crsItems.NodeText)) Endif Endscan Endwith Use In 'crsItems' Use in 'myCursor' * Tree.NodeClick *** ActiveX Control Event *** LPARAMETERS node Node.ensurevisible thisform.ItemSelected(Node.Key) * Form.ItemSelected Lparameters tcNodeID this.oletree.object.Enabled = .F. && If for any reason needs to be disabled Local loRec loRec = this.GetItemFromNodeID(m.tcNodeID) * loRec - related record as object * do whatever here * ie: * with eval(loRec.ObjectHierarchy) * .SetFocus() * endwith this.oletree.object.Enabled = .T. * Form.GetItemFromNodeID Lparameters tcNodeID Local loItem * In my case all NodeID's are simply '_'+recno() Select * from myCursor ; where Val(Substr(NodeId,2)) == Val(Substr(m.tcNodeId,2)) ; into cursor crsNode Scatter name loItem memo USE in 'myCursor' USE in 'crsNode' Return loItemCetin