change from Dbf to tree and vice versa
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Could you convert this small example using Tdatabase() and using a combobox instead of btnbmp to select tree->dbf
- Code: Select all Expand view
function TestTree()
local oDlg, oBrw
USE CUSTOMER NEW
SET ORDER TO TAG STATE
GO TOP
DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL
@ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE Alias() ;
COLUMNS "STATE", "CITY", "STREET", "ZIP", "AGE" ;
CELL LINES NOBORDER
oBrw:lDisplayZeros := .f.
oBrw:CreateFromCode()
@ 10, 20 BTNBMP PROMPT "TREE" SIZE 150,30 PIXEL OF oDlg FLAT ;
WHEN oBrw:nDataType == DATATYPE_RDD ;
ACTION oBrw:SetTree( BuildTree(), { "open", "close", "go" } )
@ 10,200 BTNBMP PROMPT "DBF" SIZE 150,30 PIXEL OF oDlg FLAT ;
WHEN oBrw:nDataType != DATATYPE_RDD ;
ACTION ( CUSTOMER->( oBrw:SetRDD( nil, nil, { "STATE", "CITY", "STREET", "ZIP", "AGE" } ) ), ;
oBrw:GoTop() )
ACTIVATE DIALOG oDlg CENTERED
CLOSE CUSTOMER
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