Antonio Linares wrote:Frances,
You can use the source code for MakeTree() in samples\TestXbr3.prg
Just use the DBF instead of an ADO recordset. The source code is almost the same.
#include "FiveWin.ch"
#include "xbrowse.ch"
function Main()
local oWnd, oBrw
USE Customer
INDEX ON Field->State TO State
SET ORDER TO "State"
GO TOP
DEFINE WINDOW oWnd TITLE "DbfTree"
@ 0, 0 XBROWSE oBrw OF oWnd LINES CELL
oBrw:SetTree( BuildTree() )
oBrw:CreateFromCode()
oBrw:aCols[ 1 ]:cHeader = "State"
oWnd:oClient = oBrw
ACTIVATE WINDOW oWnd
return nil
static function BuildTree()
local oTree, cState
TREE oTree
while ! Eof()
if Empty( cState )
_TreeItem( Customer->State ):Cargo := RecNo()
TREE
cState = Customer->State
else
if cState != Customer->State
ENDTREE
cState = Customer->State
_TreeItem( Customer->State ):Cargo := RecNo()
TREE
endif
endif
if Customer->State == cState
_TreeItem( Customer->City ):Cargo := RecNo()
endif
SKIP
enddo
ENDTREE
ENDTREE
GO TOP
return oTree
#include "FiveWin.ch"
#include "xbrowse.ch"
function Main()
local oWnd, oBrw
USE Customer
INDEX ON Field->State TO State
SET ORDER TO "State"
GO TOP
DEFINE WINDOW oWnd TITLE "DbfTree"
@ 0, 0 XBROWSE oBrw OF oWnd LINES CELL
oBrw:SetTree( BuildTree(), { "open", "close", "go" } )
oBrw:CreateFromCode()
oBrw:aCols[ 1 ]:cHeader = "State"
oWnd:oClient = oBrw
ACTIVATE WINDOW oWnd
return nil
static function BuildTree()
local oTree, cState
TREE oTree
while ! Eof()
if Empty( cState )
_TreeItem( Customer->State ):Cargo := RecNo()
TREE
cState = Customer->State
else
if cState != Customer->State
ENDTREE
cState = Customer->State
_TreeItem( Customer->State ):Cargo := RecNo()
TREE
endif
endif
if Customer->State == cState
_TreeItem( Customer->City ):Cargo := RecNo()
endif
SKIP
enddo
ENDTREE
ENDTREE
GO TOP
return oTree
open BITMAP "c:\fwh\bitmaps\16x16\folder2.bmp"
close BITMAP "c:\fwh\bitmaps\16x16\folder.bmp"
go BITMAP "c:\fwh\bitmaps\16x16\go.bmp"
#include "FiveWin.ch"
#include "xbrowse.ch"
function Main()
local oWnd, oBrw
USE Customer
INDEX ON Field->State TO State
SET ORDER TO "State"
GO TOP
DEFINE WINDOW oWnd TITLE "DbfTree"
@ 0, 0 XBROWSE oBrw OF oWnd LINES CELL
oBrw:SetTree( BuildTree(), { "open", "close", "go" } )
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 1 ] HEADER "Last"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] HEADER "First"
oBrw:CreateFromCode()
oBrw:aCols[ 1 ]:cHeader = "State"
oWnd:oClient = oBrw
ACTIVATE WINDOW oWnd
return nil
static function BuildTree()
local oTree, cState
TREE oTree
while ! Eof()
if Empty( cState )
_TreeItem( Customer->State ):Cargo := { Space( 20 ), Space( 20 ) }
TREE
cState = Customer->State
else
if cState != Customer->State
ENDTREE
cState = Customer->State
_TreeItem( Customer->State ):Cargo := { Space( 20 ), Space( 20 ) }
TREE
endif
endif
if Customer->State == cState
_TreeItem( Customer->City ):Cargo := { Customer->Last, Customer->First }
endif
SKIP
enddo
ENDTREE
ENDTREE
GO TOP
return oTree
METHOD KeyChar( nKey, nFlags ) CLASS TXBrowse
...
case nKey == VK_RETURN
oCol := ::SelectedCol()
if oCol:nEditType > 0
...
else
If( ::oTreeItem:oTree != nil,( ::oTreeItem:Toggle(), ::Refresh() ),) // new !!!
endif
...
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
for %%f in (*.prg) do c:\harbour\bin\harbour %%f /n /ic:\fwh\include;c:\harbour\include
for %%f in (*.c) do c:\bcc55\bin\bcc32 -c -Ic:\bcc55\include;c:\harbour\include %%f
for %%f in (*.obj) do c:\bcc55\bin\tlib fiveh.lib -+ %%f /0 /P32,,
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Silvio.Falconi and 44 guests