Page 1 of 1

More on browse.

PostPosted: Sun Jun 01, 2008 7:22 am
by HunterEC
A couple questions regarding TWBrowse:
1. How can I paint alternate rows in different colors ?
2. Is there a way to display a header/footer as part of the TBrowse dialog ?
3. Paint a cell (field/column) based on the data contents, i.e. outstanding
balances in red ?

Thank you.

Re: More on browse.

PostPosted: Sun Jun 01, 2008 3:16 pm
by Enrico Maria Giordano
HunterEC wrote:1. How can I paint alternate rows in different colors ?


Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw, lOdd := .F.

    USE TEST

    DEFINE DIALOG oDlg;
           SIZE 400, 400

    @ 0, 0 LISTBOX oBrw FIELDS TEST -> last,;
                               TEST -> first

    oBrw:bLogicLen = { || LastRec() }

    oBrw:lCellStyle = .T.

    oBrw:bSkip = { | nRec | nRec := ( oBrw:cAlias ) -> ( DbSkipper( nRec ) ),;
                            lOdd := If( nRec % 2 = 0, lOdd, !lOdd ),;
                            nRec }

    oBrw:nClrPane = { || If( lOdd, CLR_HRED, CLR_HGREEN ) }

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    CLOSE

    RETURN NIL


EMG

Re: More on browse.

PostPosted: Sun Jun 01, 2008 3:18 pm
by Enrico Maria Giordano
HunterEC wrote:2. Is there a way to display a header/footer as part of the TBrowse dialog ?


No way using TWBrowse, as far as I know. Try other browses (TCBrowse? TXBrowse?).

EMG

Re: More on browse.

PostPosted: Sun Jun 01, 2008 3:28 pm
by Enrico Maria Giordano
HunterEC wrote:3. Paint a cell (field/column) based on the data contents, i.e. outstanding balances in red ?


Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    USE TEST

    DEFINE DIALOG oDlg;
           SIZE 400, 400

    @ 0, 0 LISTBOX oBrw FIELDS TEST -> last,;
                               TEST -> first

    oBrw:bLogicLen = { || LastRec() }

    oBrw:nClrPane = { | nCol | If( nCol = 1 .AND. FIELD -> last = "A", CLR_HRED, CLR_HGREEN ) }

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    CLOSE

    RETURN NIL


EMG

PostPosted: Tue Jun 03, 2008 2:50 pm
by HunterEC
Enrico: thank you very much for your help. On your last example all cells are painted green. Is there some sort on bug or I am missing something ? (I am compiling with xHarbour). Thank you.

PostPosted: Tue Jun 03, 2008 3:39 pm
by Enrico Maria Giordano
You have to use FWH 8.05.

EMG