James
- Code: Select all Expand view
/*
Purpose : TXBrowse with alternating row colors
Author : James Bott
Language: FWH
Date : 1/20/2008
*/
#include "fivewin.ch"
#include "xbrowse.ch"
#define COLOR_LIGHT rgb(255,255,235)
#define COLOR_DARK rgb(192,208,179)
function main()
local oWnd,oBrw,oCust,oCol,lClrFlag
oCust:= TData():new(,"customer")
oCust:use()
define window oWnd
oBrw := TXBrowse():New( oWnd )
oCol := oBrw:AddCol()
oCol:cHeader := "First"
oCol:bStrData := { || oCust:first }
oCol := oBrw:AddCol()
oCol:cHeader := "Last"
oCol:bStrData := { || oCust:last }
// Setup alternating row flag
lClrFlag:=.f.
oBrw:bSkip:={| nRecs | (nRecs:= oCust:skipper( nRecs ), lClrFlag:= if( nRecs % 2 = 0, lClrFlag,!lClrFlag), nRecs) }
// Define alternating row colors
oBrw:bClrStd:= {|| if(lClrFlag,{ CLR_BLACK, COLOR_LIGHT },{ CLR_BLACK, COLOR_DARK }) }
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:bBookMark := {| n | iif( n == nil,(oCust:RecNo()),(oCust:GoTo(n)) ) } // Required!
oBrw:cAlias := oCust:cAlias
oBrw:lRecordSelector:=.f.
// This must be at the end of browse code as it initializes the columns
// E.G. Cols inherit row colors from the parent browse
oBrw:CreateFromCode()
oWnd:oClient:= oBrw
activate window oWnd
return nil