FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Xbrowse Tree
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Xbrowse Tree
Posted: Thu Jan 29, 2009 05:35 PM
If I have a dbf with five fields

fr1,fr2,fr3,fr4,fr5 each field NUMERIC 2

type

(1,0,0,0,0)
(1,1,0,0,0)
(1,1,1,0,0)
(1,1,2,0,0)
(1,2,0,0,0)

can I use xbrowse instead listbox


FUNCTION FrTreeLoad( oTree )
LOCAL oDatabase
LOCAL nStep
LOCAL oLink
LOCAL oLink1, oLink2, oLink3, oLink4, oLink5
LOCAL N1 := 0
LOCAL N2 := 0
LOCAL N3 := 0
LOCAL N4 := 0
oLink := oTree:GetRoot()
SELECT FR
FR->(DbGoTop())
DO WHILE ! FR->(EOF())
路路路IF FR->FrN2 == 0
路路路路路路oLink1 := oLink:AddLastChild(FR->FrTipo,IIF(FR->FrHoja,1,2),IIF(FR->FrHoja,1,2),.t.)
路路路路路路oLink1:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
路路路ELSEIF FR->FrN3 == 0
路路路路路路oLink2 := olink1:AddLastChild(FR->FrTipo,IIF(FR->FrHoja,1,2),IIF(FR->FrHoja,1,2),.t.)
路路路路路路oLink2:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
路路路ELSEIF FR->FrN4 == 0
路路路路路路oLink3 := olink2:AddLastChild(FR->FrTipo,IIF(FR->FrHoja,1,2),IIF(FR->FrHoja,1,2),.t.)
路路路路路路oLink3:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
路路路ELSEIF FR->FrN5 == 0
路路路路路路oLink4 := olink3:AddLastChild(FR->FrTipo,IIF(FR->FrHoja,1,2),IIF(FR->FrHoja,1,2),.t.)
路路路路路路oLink4:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
路路路ELSE
路路路路路路oLink5:= oLink4:AddLastChild(FR->FrTipo,IIF(FR->FrHoja,1,2),IIF(FR->FrHoja,1,2),.t.)
路路路路路路oLink5:Cargo := Str(FR->Frn1,2)+Str(FR->Frn2,2)+Str(FR->Frn3,2)+Str(FR->Frn4,2)+Str(FR->Frn5,2)
ENDIF
FR->(DbSkip())
ENDDO
oTree:UpdateTV()
oTree:SetFocus()
RETURN NIL
Best Regards, Saludos



Falconi Silvio
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Xbrowse Tree
Posted: Thu Jan 29, 2009 05:47 PM

Dear Mr.Silvio,

viewtopic.php?f=3t=13979start=21

Regards

Anser

&&

Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Xbrowse Tree
Posted: Thu Jan 29, 2009 05:53 PM

sorry but this topic talk for checkbox and not tree !!!!!!!!!!!!

Best Regards, Saludos



Falconi Silvio
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Xbrowse Tree
Posted: Thu Jan 29, 2009 05:56 PM

Dear Mr.silvio,

Oops I am sorry, I misunderstood.

My intention was to show you that Tree like data can be displayed in xBrowse and the sample code is also available which you can use it as a reference.

I thought that it might be helpful to you. :D

Regards

Anser

Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Xbrowse Tree
Posted: Thu Jan 29, 2009 06:00 PM

Sorry, but in your source code I cannot see command tree of xbrowse

Best Regards, Saludos



Falconi Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Xbrowse Tree
Posted: Thu Jan 29, 2009 06:04 PM
THIS SAMPLE of linares USE SETREE COMAND




#include "fivewin.ch"
#include "xbrowse.ch"


function main()

local oWnd, oBrw
local aData := { ;
{ "NY", " ", 300, 3000 }, ;
{ "NY", "ONE ", 100, 1000 }, ;
{ "NY", "TWO ", 200, 2000 }, ;
{ "TX", " ",1100,11000 }, ;
{ "TX", "THREE ", 300, 3000 }, ;
{ "TX", "FOUR ", 350, 3500 }, ;
{ "TX", "FIVE ", 450, 4500 } }
// Should start with data grouped and softed like above


DEFINE WINDOW oWnd

@ 0,0 XBROWSE oBrw OF oWnd ;
ARRAY aData AUTOCOLS

oBrw:CreateFromCode()
oBrw:SetTree( nil, { "OPEN", "CLOSE", "GREEN" } ) // build tree structure from the array automatically
oWnd:oClient := oBrw

ACTIVATE WINDOW oWnd


return nil
Best Regards, Saludos



Falconi Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Xbrowse Tree
Posted: Thu Jan 29, 2009 06:29 PM

NOW i WISH CREATE THE DATA DIRECTLY FROM A DBF
ANY HELP ?

Best Regards, Saludos



Falconi Silvio
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Xbrowse Tree
Posted: Thu Jan 29, 2009 09:39 PM
// Convert a dbf to an array
function dbf2array(cFile)
   local aArray:={}
   local aRec:={} 
   local nArea:= select()
   use ( cFile ) new shared
   do while ! eof()
      aRec:={}
      for i= 1 to fcount()
        AADD( aRec, FIELDGET( i ) )
      next
      aadd( aArray, aRec)
      skip
   enddo
   use
   select( nArea )
return aArray
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion