FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Borrar Items de Treeview
Posts: 625
Joined: Wed Mar 14, 2007 06:49 PM
Borrar Items de Treeview
Posted: Sun Dec 13, 2015 04:51 AM
Saludos a Todos:

Estoy armando un Tree en base al ejemplo re.prg, ya armado un arbol de items como puedo borrar items, he buscado y probado por varias formas pero no funciona, hay alguna forma de poderlo realizar..

Soluciones y Dise帽o de Software
Damos Soluciones...

I.S.C. Victor Daniel Cuatecatl Leon
Director y Dise帽ador de Proyectos

http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Borrar Items de Treeview
Posted: Sun Dec 13, 2015 09:29 AM
Victor, seria algo asi, a ver si te sirve

Code (fw): Select all Collapse
Local nSect
Local nPos
Local oIt 聽 聽:= oTree:GetSelected()
if !Empty( oIt )
聽 聽nSect := oTree:GetItemPos( oIt:oParent )
聽 聽nPos 聽:= oIt:oParent:GetItemPos( oIt )
聽 聽oIt:oParent:aItems[ nPos ]:DeleteBranches()
聽 聽oIt:oParent:DelItemPos( nPos )
endif
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 625
Joined: Wed Mar 14, 2007 06:49 PM
Re: Borrar Items de Treeview
Posted: Sun Dec 13, 2015 06:52 PM

Crist贸bal:

Como siempre muy oportuna tu ayuda... Funcion贸 de maravilla

Gracias por tu apoyo. Saludos

Soluciones y Dise帽o de Software
Damos Soluciones...

I.S.C. Victor Daniel Cuatecatl Leon
Director y Dise帽ador de Proyectos

http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Re: Borrar Items de Treeview
Posted: Wed Dec 16, 2015 01:51 PM
Hi,

Cuidado que en esta clase habia un peque帽o bug, no se si esta resuelto ahora. Lo que ocurria creo recordar es que borraba el item pero no la referencia que estaba en su padre. :-)

Yo tengo el c贸digo asi para que funcione correctamente

Code (fw): Select all Collapse
聽 聽 聽 聽 // 聽Buscamos el Padre del que cuelga este Item

聽 聽 聽 聽 聽 聽 oPadre 聽 聽 聽 聽 聽 := 聽oBranch:GetParent()聽 聽 聽 聽 
聽 聽 聽 聽 聽 聽 
聽 聽 聽 聽 聽 聽 TVDeleteItem( ::oTree:hWnd, oBranch:hItem )

聽 聽 聽 聽 // 聽TVDeleteItem borra la rama pero NO elimina de la clase el Item de la rama

聽 聽 聽 聽 聽 聽 nPosHijoenPadre 聽:= Ascan( oPadre:aItems, {|o| o:hItem == oBranch:hItem } )

聽 聽 聽 聽 聽 聽 IF nPosHijoenPadre > 0

聽 聽 聽 聽 聽 聽 聽 聽ADel ( oPadre:aItems, nPosHijoenPadre )
聽 聽 聽 聽 聽 聽 聽 聽ASize( oPadre:aItems, Len(oPadre:aItems)-1 )

聽 聽 聽 聽 聽 聽 ENDIF


Por si alguien lo necesita o quiere revisar...
Salutacions, saludos, regards

"...programar es f谩cil, hacer programas es dif铆cil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Borrar Items de Treeview
Posted: Fri Dec 18, 2015 09:09 AM
Carles,
here run ok but only for subcategory
when I try to delete a category make error
Code (fw): Select all Collapse
Application
===========
   Path and name: C:\Documents and Settings\Administrator\Desktop\tree\test.Exe (32 bits)
   Size: 2,737,664 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20140725)
   FiveWin  Version: FWHX 15.01
   Windows version: 5.1, Build 2600 Service Pack 3

   Time from start: 0 hours 1 mins 13 secs 
   Error occurred at: 12/18/15, 10:06:55
   Error description: Error BASE/1004  Class: 'NIL' has no exported method: AITEMS
   Args:
     [   1] = U   

Stack Calls
===========
   Called from:  => AITEMS( 0 )
   Called from: test.prg => MABORRA( 244 )
   Called from: test.prg => (b)TEST( 67 )
   Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK( 175 )
   Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT( 1687 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3450 )
   Called from:  => SENDMESSAGE( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND( 403 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 906 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 286 )
   Called from: test.prg => TEST( 104 )




Code (fw): Select all Collapse
   local oLink       := oTree:GetSelected()
   local cPrompt     := oLink:cPrompt
   local cCargo      := oLink:Cargo
   local nRecno      := GE->(Recno())
   local lMateria    := ( Len(cCargo) <= 40 )
   local  nNext



SELECT GE
      GE->(DbSkip())
      nNext := GE->(Recno())
      GE->(DbGoto(nRecno))

      GE->(DbDelete())
      GE->(DbPack())
      GE->(DbGoto(nNext))

      IF GE->(EOF()) .or. nNext == nRecno
         GE->(DbGoBottom())
      ENDIF


   // CANCELLO IL TREE
//      oLink:End()   //  <-----------------
       * TvDeleteItem( oTree:hWnd, oLink:hItem )
       * MyDelItem( oTree, oLink )


            //  Buscamos el Padre del que cuelga este Item

                oPadre  :=  oLink:GetParent()
                TVDeleteItem(oTree:hWnd, oLink:hItem )
            //  TVDeleteItem borra la rama pero NO elimina de la clase el Item de la rama
                nPosHijoenPadre  := Ascan( oPadre:aItems, {|o| o:hItem == oLink:hItem } )
                IF nPosHijoenPadre > 0
                   ADel ( oPadre:aItems, nPosHijoenPadre )
                   ASize( oPadre:aItems, Len(oPadre:aItems)-1 )
                ENDIF

             ENDIF

   oTree:refresh()
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1956
Joined: Fri Oct 07, 2005 07:08 PM
Re: Borrar Items de Treeview
Posted: Tue Nov 23, 2021 10:52 PM

Veo que tienen mas experiencia en tree que yo.

pueden decirme como puedo recorrerme el tree desde una punta a la otra pasando por todos los OITEM que tnega?

gracias

FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Borrar Items de Treeview
Posted: Wed Nov 24, 2021 04:30 AM

Gustavo,

oTree:Scan( bAction )

bAction recibe el par谩metro oItem y tiene que devolver un valor l贸gico indicando si se ha encontrado lo que se buscaba 贸 hay que seguir buscando :-)

{ | oItem | ..., lEncontrado }

lEncontrado es .T. 贸 .F.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion