Xbrowse Tree

Xbrowse Tree

Postby Silvio » Thu Jan 29, 2009 5: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


Code: Select all  Expand view
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
Last edited by Silvio on Thu Jan 29, 2009 5:56 pm, edited 1 time in total.
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Xbrowse Tree

Postby anserkk » Thu Jan 29, 2009 5:47 pm

Dear Mr.Silvio,

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

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Xbrowse Tree

Postby Silvio » Thu Jan 29, 2009 5:53 pm

sorry but this topic talk for checkbox and not tree !!!!!!!!!!!!
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Xbrowse Tree

Postby anserkk » Thu Jan 29, 2009 5: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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Xbrowse Tree

Postby Silvio » Thu Jan 29, 2009 6:00 pm

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

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Xbrowse Tree

Postby Silvio » Thu Jan 29, 2009 6: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
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Xbrowse Tree

Postby Silvio » Thu Jan 29, 2009 6:29 pm

NOW i WISH CREATE THE DATA DIRECTLY FROM A DBF
ANY HELP ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Xbrowse Tree

Postby James Bott » Thu Jan 29, 2009 9:39 pm

Code: Select all  Expand view
// 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 88 guests

cron