oBrw:nClrPane := {||iif( OrdKeyNo() % 2 == 0, nEvenColor, nOddColor }
// Purpose : Sample TCBrowse with alternating color rows without a database object
// Author : James Bott
// Date : 1/9/2008
#include "fivewin.ch"
#include "TCBrowse.ch" // <-- Important
function main()
local oWnd, oBrw, lClrFlag, cAlias
use customer
cAlias := alias()
define window oWnd title "TCBrowse Test"
@ 0,0 browse oBrw of oWnd update
oBrw:cAlias := cAlias
add column to browse oBrw data (cAlias)->first
add column to browse oBrw data (cAlias)->last
lClrFlag:=.f.
oBrw:bSkip:={| nRecs | (nRecs:= (cAlias)->(dbskipper( nRecs )), lClrFlag:=if(nRecs/2 = int(nRecs/2), lClrFlag,!lClrFlag), nRecs) }
oBrw:nClrPane := { || if(lClrFlag, rgb(255,255,235), rgb(192,208,179)) }
oBrw:nLineStyle:=0
oWnd:oClient:= oBrw
activate window oWnd
return nil
If the index is large, this function could take some time to complete because index keys are literally counted until the current key is reached.
If usFilterOption contains ADS_RESPECTFILTERS, the Advantage Client Engine must skip through all records referenced by keys in the index that pass the filter and/or scope and count them until the current key is reached. Thus, with large indexes where many records pass the filter and/or keys pass the scope, this function can be very slow.
nageswaragunupudi wrote:Mr James
Your solution is a lot more elegant and works well. I agree we can drop considering any other alternative approaches.
oBrw:nClrPane := { |nRow| iif( nRow % 2 == 0, rgb(255,255,235), rgb(192,208,179)) }
James Bott wrote:
- Code: Select all Expand view RUN
nRecs/2 = int(nRecs/2)
nRecs % 2 = 0
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 68 guests