thisform.savingtv(thisform.mytreeview) procedure savingtv Lparameters myTV Local nwindice,nwultindice if used("cur_tv") sele cur_tv use endif sele 0 create cursor cur_tv (buffer_rec c(250)) With myTV nwind = .Nodes(1).Root.FirstSibling.Index nwultindice = .Nodes(1).Root.LastSibling.Index this.Geting_Sub_Nodes(nwind, myTV) Do While nwindice # nwultindice nwindice = .Nodes(nwindice).Next.Index this.Geting_Sub_Nodes(nwindice,toTV) Enddo Endwith Return procedure Geting_Sub_Nodes Lparameters tnIndex, myTV Local tnIndex, nwindex, nwlastindex With myTV this.Writing_to_Node(tnIndex,myTV) If .Nodes(tnIndex).Children > 0 nwindex = .Nodes(tnIndex).Child.Index nwlastindex = .Nodes(tnIndex).Child.LastSibling.Index this.Geting_Sub_Nodes(nwindex,myTV) Do While nwindex # nwlastindex nwindex = .Nodes(nwindex).Next.Index this.Geting_Sub_Nodes(nwindex,myTV) Enddo Endif Endwith procedure Writing_to_Node Lparameters tnCurIndex, myTV Local lnRootIndex, lnIndex, lcPrefix, lcKey, lnLevel lnIndex = tnCurIndex With myTV lnRootIndex = .Nodes(lnIndex).Root.Index lcPrefix = ' ' + .Nodes(lnIndex).Text lnLevel = 0 IF .Nodes(lnIndex).TAG = "LEVEL1" && I use it when populating a treeview.. for 1st. parent else Do While lnIndex # lnRootIndex .and. .Nodes(lnIndex).tag # "LEVEL1" lnIndex = iif(type(".Nodes(lnIndex).Parent.Index")<>"U",.Nodes(lnIndex).Parent.Index, lnRootIndex) lcPrefix = Iif(.Nodes(lnIndex).LastSibling.Index = ; lnIndex,' ',' ')+Space(3)+lcPrefix lnLevel = lnLevel + 1 Enddo endif m.buffer_rec = lcPrefix insert into cur_tv from memvar EndwithAs result the function will return a cursor: cur_tv