I am giving 4 methods. Choose any of the methods depending on the favorite programming style. All produce the same results.
Method 3 ( Very old XBrowse syntax. Only way before XBrowse commands were available )
Method 4 works only with latest FWH.
Choose any method, programming with XBrowse is a lot more easier than other browses.
Code: Select all
#include "fivewin.ch"
#include "xbrowse.ch"
//----------------------------------------------------------------------------//
function Main()
Method3()
return nil
//----------------------------------------------------------------------------//
function Method1 // Similar to WBrowse syntax
local aData := { { "One", { 1, 2, 3, 4 } }, ;
{ "Two", { 5, 6, 7, 8 } }, ;
{ "Three", { 9, 8, 7, 6 } } }
local oDlg, oBrw
DEFINE DIALOG oDlg SIZE 300,200 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
COLUMNS 1 ;
FIELDS { || oBrw:aRow[ 2 ][ 1 ] }, ;
{ || oBrw:aRow[ 2 ][ 2 ] }, ;
{ || oBrw:aRow[ 2 ][ 3 ] }, ;
{ || oBrw:aRow[ 2 ][ 4 ] } ;
HEADERS "Name", "A1", "A2", "A3", "A4" ;
PICTURES nil, "999", "999", "999", "999" ;
ARRAY aData CELL LINES NOBORDER
oBrw:createFromCode()
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//
function Method2 // Similar to TCBrowse syntax
local aData := { { "One", { 1, 2, 3, 4 } }, ;
{ "Two", { 5, 6, 7, 8 } }, ;
{ "Three", { 9, 8, 7, 6 } } }
local oDlg, oBrw
method2()
return nil
DEFINE DIALOG oDlg SIZE 300,200 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
COLUMNS 1 HEADERS "Name" ;
ARRAY aData CELL LINES NOBORDER
ADD TO oBrw DATA oBrw:aRow[ 2 ][ 1 ] PICTURE "999" HEADER "A1"
ADD TO oBrw DATA oBrw:aRow[ 2 ][ 2 ] PICTURE "999" HEADER "A2"
ADD TO oBrw DATA oBrw:aRow[ 2 ][ 3 ] PICTURE "999" HEADER "A3"
ADD TO oBrw DATA oBrw:aRow[ 2 ][ 4 ] PICTURE "999" HEADER "A4"
oBrw:createFromCode()
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//
function Method3 // Old XBrowse syntax, when commands were not available
local aData := { { "One", { 1, 2, 3, 4 } }, ;
{ "Two", { 5, 6, 7, 8 } }, ;
{ "Three", { 9, 8, 7, 6 } } }
local oDlg, oBrw, n
DEFINE DIALOG oDlg SIZE 300,200 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
COLUMNS 1 HEADERS "Name" ;
ARRAY aData CELL LINES NOBORDER
for n := 1 to Len( aData[ 1 ][ 2 ] )
WITH OBJECT oBrw:AddCol()
:cHeader := "A" + Str( n, 1 )
:bEditValue := SetColBlock( oBrw, n ) // Note: Please never use bStrData
:cEditPicture := "999"
END
next
oBrw:createFromCode()
ACTIVATE DIALOG oDlg CENTERED
return nil
static function SetColBlock( oBrw, nCol )
return { || oBrw:aRow[ 2 ][ nCol ] }
//----------------------------------------------------------------------------//
function Method4 // Present recommended but only with latest fwh
local aData := { { "One", { 1, 2, 3, 4 } }, ;
{ "Two", { 5, 6, 7, 8 } }, ;
{ "Three", { 9, 8, 7, 6 } } }
local oDlg, oBrw
// Works only with latest FWH
DEFINE DIALOG oDlg SIZE 300,200 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
COLUMNS 1, { || oBrw:aRow[ 2 ][ 1 ] }, ;
{ || oBrw:aRow[ 2 ][ 2 ] }, ;
{ || oBrw:aRow[ 2 ][ 3 ] }, ;
{ || oBrw:aRow[ 2 ][ 4 ] } ;
HEADERS "Name", "A1", "A2", "A3", "A4" ;
PICTURES nil, "999", "999", "999", "999" ;
ARRAY aData CELL LINES NOBORDER
oBrw:createFromCode()
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//