FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Listbox color for a single column
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Listbox color for a single column
Posted: Thu Jun 12, 2008 12:52 AM

To All

I am using the standard TWBrowse ( listbox ) and I want to be able to turn a cell in a row ( column status ) a certain color .. crudely like this

col1 col2 col3 status

xxx xxx xxx RED
xxx xxx xxx GREEN
xxx xxx xxx YELLOW

I can turn the entire row a particular color based on the data in the "status" column .. but turning the entire row a particular color gets too busy... just want to turn the "status" cell in each row a certain color based on the data in that cell.

Any Ideas ??

Thanks
Rick Lipkin

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Listbox color for a single column
Posted: Thu Jun 12, 2008 12:29 PM
Try using nClrPane property:

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


EMG
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Listbox color for a single column
Posted: Tue Jul 15, 2008 09:57 PM

Enrico

Sorry for the late post .. first chance I have had to get back to this color column issue .. I looked at the samples brwcolor.prg .. however it does not use table fields and it is hard to interpret the array values ..

Here is my code .. I want to look at the last defined column and test for the value of "row_color" = "GREEN" to turn that column green.

The sample code turns the entire row green .. not just the last column .. using standard Twbrowse FWH class ..

Rick Lipkin

//----- Reporting tab

REDEFINE LISTBOX oLBX FIELDS    ;
if(oRsRpt:eof, , oRsRpt:Fields("DATE_REPORTED"):Value),;
if(oRsRpt:eof,str(0,4) , str(oRsRpt:Fields("reporting_interval"):Value,4)),;
if(oRsRpt:eof, , oRsRpt:Fields("projmgr"):Value),;
if(oRsRpt:eof, , oRsRpt:Fields("start_date"):Value),;
if(oRsRpt:eof, , oRsRpt:Fields("end_date"):Value),;
if(oRsRpt:eof, , str(oRsRpt:Fields("est_budget"):Value,12,2)),;
if(oRsRpt:eof, , oRsRpt:Fields("final"):Value),;
if(oRsRpt:eof, , oRsRpt:Fields("row_color"):Value), ;
HEADERS "Date Rpt",    ;
        "Int",         ;
        "ProjMgr",     ;
        "StartDt",     ;
        "EndDt",       ;
        "EstBudt",     ;
        "Final",       ;
        "Status"       ;
SIZES 80,40,80,80,80,90,50,70 ;
ID 111 of oFld1:aDialogs[1] ;
ON DBLCLICK( _Rptview(oRsRpt, oRsProj, "V", cPROJECTEID) ,;
oLbx:ReFresh(),        ;
oLbx:SetFocus(), SysReFresh() );
UPDATE

IF .not. oRsRpt:eof
   oLbx:bLogicLen := { || oRsRpt:RecordCount }
   oLbx:bGoTop    := { || oRsRpt:MoveFirst() }
   oLbx:bGoBottom := { || oRsRpt:MoveLast() }
   oLbx:bSkip     := { | nSkip | Skipper( oRsRpt, nSkip ) }
   oLbx:cAlias    := "ARRAY"

   oLbx:nClrPane = { | nCOL | if( oRsRpt:Fields("row_color"):Value = "GREEN", CLR_GREEN, CLR_WHITE ) }

ENDIF
Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
Listbox color for a single column
Posted: Wed Jul 16, 2008 12:29 AM
Rick Lipkin wrote:The sample code turns the entire row green .. not just the last column .. using standard Twbrowse FWH class ..
Hi Rick:

I'm afraid that standard TWBrowse is not a column based browser, then you can't define column or cell colors. That is possible only with TCBrowse or TXBrowse talking about standard FWH browsers.

Regards.

Manuel Mercado.
manuelmercado at prodigy dot net dot mx
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Listbox color for a single column
Posted: Wed Jul 16, 2008 07:15 AM
This is not true. From FWH May 2008 whatsnew.txt:

* Enhancement: Class TWBrowse DATA nClrPane if used as a codeblock, now receives a numeric
parameter with the column to be displayed, so you can change the color of a single cell.
Please review samples\BrwColor.prg.


EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Listbox color for a single column
Posted: Wed Jul 16, 2008 07:20 AM
Rick Lipkin wrote:The sample code turns the entire row green .. not just the last column .. using standard Twbrowse FWH class ..


It is a bug that I already reported here:

http://forums.fivetechsoft.com/viewtopic.php?t=11385

EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Listbox color for a single column
Posted: Wed Jul 16, 2008 10:10 AM

Enrico,

Already fixed! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Listbox color for a single column
Posted: Wed Jul 16, 2008 11:09 AM

Great, thank you!

EMG

Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
Listbox color for a single column
Posted: Wed Jul 16, 2008 04:15 PM
Enrico Maria Giordano wrote:This is not true. From FWH May 2008 whatsnew.txt:Enhancement: Class TWBrowse DATA nClrPane if used as a codeblock, now receives a numeric
parameter with the column to be displayed, so you can change the color of a single cell
Sorry :-) I'm not updated

Best regards.

Manuel Mercado
manuelmercado at prodigy dot net dot mx
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Listbox color for a single column
Posted: Wed Jul 16, 2008 05:15 PM

Antonio

What was the fix ?? something I can modify on my end ??

Rick Lipkin

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Listbox color for a single column
Posted: Wed Jul 16, 2008 06:47 PM

Antonio

I made the change in Wbrowse and included it to my compile list .. I had to modify the code block .. here was the fix:

oLbx:nClrPane = { | nCOL | if( (nCOL = 8 .and. oRsRpt:Fields("row_color"):Value = "GREEN"), CLR_GREEN, CLR_WHITE ) }

Thanks
Rick Lipkin

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Listbox color for a single column
Posted: Wed Jul 16, 2008 08:11 PM

Rick,

Yes, you can implement the codeblock the way you need it

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Listbox color for a single column
Posted: Wed Jul 16, 2008 11:08 PM

Antonio

You might want to look a nClrText as well .. I have not had a chance to track it down and look in Wbrowse .. I wanted clr_white text on a clr_green background ..

nClrText seems to exibit the same row behavoir and does not seem to respect the cell designation.

Rick LIpkin

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Listbox color for a single column
Posted: Thu Jul 17, 2008 08:39 AM

Rick,

Fixed, the same n was missing in Eval( nClrTxt, n )

Thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Listbox color for a single column
Posted: Thu Jul 17, 2008 08:40 AM
This is the right code:
               SetTextColor( hDC, If( nColAct != nil, If( ValType( nClrTxt ) == "B",;
                             Eval( nClrTxt, n ), nClrTxt ),;
                             If( ValType( nClrText ) == "B", Eval( nClrText, n ), nClrText ) ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com