xbrowse...Color a cell

xbrowse...Color a cell

Postby hag » Wed Nov 12, 2008 5:01 am

I need some code to color a cell on screen and print, in an xbrowse when there is a value in the cell.

Thanks
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby JC » Wed Nov 12, 2008 7:04 pm

Harvey,

I don't understanding what you want but, this example changes the colors of a xbrowse row:
Code: Select all  Expand view
oBrw:bClrStd := {|| iif( empty( oBrw:aCols[1]:Value() ) ), { CLR_WHITE, CLR_HGRAY }, { CLR_BLACK, getSysColor( 5 ) } ) }
oBrw:bClrSel      := { || { CLR_BLACK, GetSysColor( COLOR_INACTIVECAPTION ) } }
oBrw:bClrSelFocus := { || { CLR_BLACK, GetSysColor( COLOR_HIGHLIGHT ) } }
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby James Bott » Wed Nov 12, 2008 9:41 pm

Harvey,

Maybe this is what you want?

Code: Select all  Expand view
FOR I = 1 TO LEN(oBrw:aCols)
   oBrw:aCols[I]:bClrStd := {|| {CLR_BLUE, If( DET->SDETAIL, CLR_YELLOW, CLR_WHITE)  } }
NEXT


Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby hag » Sun Nov 16, 2008 5:51 am

Thanks for the replys. I've been out of town and not able to try suggestions. They don't seem to work.

I need to color a cell (just one cell) when a variable is inacted. I'm using oBrw from resources. The variable is a calculation of several numeric variables. If the result is 500 or more, color the cell.

Code: Select all  Expand view
FOR I = 1 TO LEN(oBrw:aCols)
oBrw:aCols[I]:bClrStd := {|| {CLR_BLUE, If( DET->SDETAIL, CLR_YELLOW, CLR_WHITE)  } }
NEXT


I tried this:
Code: Select all  Expand view
FOR I = 1 TO LEN(oBrw:aCols)
oBrw:aCols[I]:bClrStd := {|| {CLR_BLUE, If( nVara-nVarb, CLR_YELLOW, CLR_WHITE)  } }
NEXT


At the column browse I did nothing except the same calculation.

Nothing happened.


Need some help. Thanks
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby Daniel Garcia-Gil » Sun Nov 16, 2008 6:43 am

try...
Code: Select all  Expand view
FOR I = 1 TO LEN(oBrw:aCols)
   oBrw:aCols[I]:bClrStd := {|| If( nVara-nVarb, {CLR_BLUE,  CLR_YELLOW}, {CLR_BLUE, CLR_WHITE } ) } 
NEXT
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Postby Carlos Mora » Sun Nov 16, 2008 9:27 am

hag wrote:I tried this:
Code: Select all  Expand view
FOR I = 1 TO LEN(oBrw:aCols)
oBrw:aCols[I]:bClrStd := {|| {CLR_BLUE, If( nVara-nVarb, CLR_YELLOW, CLR_WHITE)  } }
NEXT




May be I'm missing something but... the function IF() does need a LOGICAL as first parameter ¿Isn't it? Something like ( nVara-nVarb ) > 500

regards
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Postby James Bott » Sun Nov 16, 2008 3:33 pm

Carlos is right, it needs to be a logical. Also, you need to use the data in the cell, rather than vars. Something like this:

Code: Select all  Expand view
FOR I = 1 TO LEN(oBrw:aCols)
oBrw:aCols[I]:bClrStd := {|| {CLR_BLUE, If( val(eval(oBrw:aCols[i]:bStrData))>500 , CLR_YELLOW, CLR_WHITE)  } }
NEXT


The above FOR/NEXT is only if you want all columns setup this way. If you only want one column then just do this (where i is the number of the column):

Code: Select all  Expand view
oBrw:aCols[I]:bClrStd := {|| {CLR_BLUE, If( val(eval(oBrw:aCols[i]:bStrData))>500 , CLR_YELLOW, CLR_WHITE)  } }



Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Cell-Color

Postby ukoenig » Sun Nov 16, 2008 4:24 pm

Hello James,

What happens after Col-swapping ?
I think, it has to be a function.

Image

Image

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby James Bott » Sun Nov 16, 2008 4:41 pm

Uwe,

Good point. It would be better to define it when defining the column.

Code: Select all  Expand view
oCol:bClrStd := {|| {CLR_BLUE, If( val(eval(oCol:bStrData))>500 , CLR_YELLOW, CLR_WHITE)  } }


James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby hag » Sun Nov 16, 2008 6:01 pm

Thanks all Still having problems:


It colors the row perfectly with this code:

Code: Select all  Expand view
oBrw:bClrStd := {|| {CLR_BLACK,CLR_WHITE, If( nVara-nVarb > 500, CLR_YELLOW, CLR_WHITE)  } }


I can't get the color confined to a single cell. I'm using xbrowse, column browse from resources and the code doesn't like oCol or aCol.

Any suggsetions?
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby Daniel Garcia-Gil » Sun Nov 16, 2008 6:59 pm

oBrw:aCols[ n ]:bClrStd := {|| {CLR_BLACK,CLR_WHITE, If( oBrw:aRow[ z ] > 500, CLR_YELLOW, CLR_WHITE) } }

n = column get singel cell
z = column into row to evalue (cell)

it evalue cell by cell

my case...
oBrw:aCols[ 3 ]:bClrStd := { ||{ CLR_BLACK,if (oBrw:aRow[ 1 ] = "NBA",CLR_RED,CLR_WHITE) } }
Image

sorry my english :oops:
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Postby hag » Mon Nov 17, 2008 10:50 pm

Thanks for all the help. I have it working to highlight row but not single cell. aCol[] and aRow[] is the problem. How do i get the number of the array elements for these?
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Cell-Color

Postby ukoenig » Tue Nov 18, 2008 4:58 pm

Cell-color for a certain field-value :

Image

Code: Select all  Expand view

#include "FiveWin.ch"
#include "xbrowse.ch"
#define WID  350
#define HGT  200

REQUEST DBFCDX

function Main()
local oDlg, oBrw , oCol, nFor

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-18
USE CUSTOMER NEW SHARED VIA "DBFCDX"
SET ORDER TO TAG FIRST
GO TOP

DEFINE DIALOG oDlg SIZE 2*WID,2*HGT PIXEL  FONT oFont

oBrw := TXBrowse():New( oDlg )

oBrw:nMarqueeStyle       := MARQSTYLE_HIGHLCELL
oBrw:nColDividerStyle    := LINESTYLE_BLACK
oBrw:nRowDividerStyle    := LINESTYLE_BLACK
oBrw:lColDividerComplete := .t.

oCol := oBrw:AddCol()
oCol:AddResource( "CLIP" )
oCol:AddResource( "star" )
oCol:bLClickHeader = { | nMRow, nMCol, nFlags, Self | ;
If( ::nHeadBmpNo == 2, ::nHeadBmpNo := 1, ::nHeadBmpNo := 2 ), ::oBrw:Refresh() }
oCol:cHeader       := "CLIP"
oCol:nHeadBmpNo    := 1
oCol:nHeadBmpAlign := AL_RIGHT

oCol := oBrw:AddCol()
oCol:bStrData  := { || _FIELD->First}
oCol:cHeader   := "First"
oCol:oDataFont := oFont

oCol := oBrw:AddCol()
oCol:bStrData := { || _FIELD->Last}
oCol:cHeader  := "Last"
// ----------- Field-color ----------
oCol:bClrStd  := { || IIF( _FIELD->LAST = "Crystal", ;
{ 16777215,128 }, { 16777215, 6534803 } ) }
// -----------------------------------

oCol := oBrw:AddCol()
oCol:AddResource("GREEN")
oCol:AddResource("RED")
oCol:cHeader  := "Married"
oCol:bBmpData   := { || iif( _FIELD->Married, 1, 2) }
oCol:bStrData   := { || iif( _FIELD->Married, "Yes", "No ")}
oCol:bEditValue := { || _FIELD->Married }
oCol:nDataStyle := oCol:DefStyle( AL_RIGHT, .T.)
oCol:nEditType := EDIT_LISTBOX
oCol:aEditListTxt   := { "Yes", "No"}
oCol:aEditListBound := { .t., .f. }
oCol:bOnPostEdit := {|o, v| (DBRLOCK(), _FIELD->Married := v, DBUNLOCK() ) }

oBrw:SetRDD()

oBrw:CreateFromCode()

ACTIVATE DIALOG oDlg CENTER ON INIT ( oDlg:oClient := oBrw, oDlg:Resize() )

CLOSE DATABASE

RETURN NIL




[code]

DEFINE BRUSH oBrush1 STYLE "BRICKS"

oCol:oBrush := { || IIF( _FIELD->LAST = "Crystal", oBrush1, NIL ) }
*oCol:bClrStd := { || IIF( _FIELD->LAST = "Crystal", { 16777215,128 }, { 16777215, 6534803 } ) }

Image

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby hag » Tue Nov 18, 2008 7:57 pm

Uwe and all:
My issue seems to be that I'm not using oCol:addCol() to set up colums. I'm using ADD COLUMN for each column and the oCol:bClrStd doesnt work. I'm using oBrw:bClrstd which places the color on the entire row. Is there a way to have it color the cell when using ADD COLUMN?
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby James Bott » Tue Nov 18, 2008 9:45 pm

ADD COLUMN oCol TO oBrw...

oCol:bClrstd:=...
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 100 guests