Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recursive method?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00787723
Message ID:
00787729
Vues:
21
Formated for readability.

>Hi all
>
>I have 2 treeviews in a form, and just want to drag (move) a node from one control to the other.. and all its childs.
>I wrote this code but it is not working ... it gets only the first child of every nested level... I mean:
>root
>   level1_1
>      level2_1
>         level3_1
>         level3_2
>         level3_3
>      level2_2
>         level3_4
>
>if I drag the node "level1_1" it only moves :
>root
>   level1_1
>       level2_1
>           level3_1
>heres the code... if anyone can help me... GetChilds is the method that I have the problem:
>Procedure oletreeview.OLEDragDrop
>  *** ActiveX Control Event ***
>  Lparameters data, effect, button, shift, x, y
>  If Data.Getformat(1)     &&CF_TEXT
>    With this
>      If !isnull(thisform.nodx) and type(".DropHighLight") = "O" and !isnull(.DropHighlight)
>
>        loSource = thisform.nodx
>        loTarget = .DropHighlight
>
>	* no dejo mover la raiz
>	if loSource.key # loSource.root.key
>           If loSource.Key # loTarget.key
>              lcSourceKey = loSource.Key
>              lcSourceText = loSource.Text
>
>              * CONTROLAR QUE NO SE FORMEN CICLOS
>              ON ERROR DO CircularError WITH ;
>              ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO( )
>
>              * CONTROLAR SI YA EXISTE EL NODO	
>	      if type('.Nodes(lcSourceKey)') # 'O'
>	         * NO EXISTE
>		 oNode=.nodes.add(loTarget.Key, tvwchild,lcSourceKey, lcSourceText,losource.image)
>
>                 * Me llevo sus hijos
>		 o = thisform.oletreeview2
>		 .GetChilds(o, lcsourcekey)
>
>		 .SelectedItem = oNode
>	       else
>		  * YA EXISTE
>		  if losource.root.key = lotarget.root.key
>		     loSource.Parent = loTarget
>                  endif
>	       endif
>	    Endif
>	ELSE
>		messagebox('ERROR: No se puede mover la raiz')
>	endif
>      Endif
>    Endwith
>  Endif
>  This.DropHighlight = .null.
>
>  ON ERROR
>
>Endproc
>
>
>procedure Oletreeview.GetChilds
>Lparameters o, lcsourcekey
>
>   i = 2	&& no considero la raiz
>   do while i <= o.nodes.count
>      if o.nodes[i].parent.key = lcsourcekey	&& es hijo del que movi
>         nuevokey = o.nodes[i].key
>	 nuevotext = o.nodes[i].text
>	 if type('.Nodes(nuevokey)') # 'O'	&& no existe
>	    nuevo = .nodes.add(lcsourcekey,tvwchild,nuevokey,nuevotext,"trkvta")
>
>
>	    .GetChilds( o, nuevokey )   && RECURSIVO ??????
>         endif	
>       endif
>       i = i + 1
>    enddo
>	
>endproc
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform