xbrowse...Color a cell
xbrowse...Color a cell
I need some code to color a cell on screen and print, in an xbrowse when there is a value in the cell.
Thanks
Thanks
Thank you
Harvey
Harvey
Harvey,
I don't understanding what you want but, this example changes the colors of a xbrowse row:
I don't understanding what you want but, this example changes the colors of a xbrowse row:
Code: Select all | Expand
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
Júlio César M. Ferreira
FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Harvey,
Maybe this is what you want?
Regards,
James
Maybe this is what you want?
Code: Select all | Expand
FOR I = 1 TO LEN(oBrw:aCols)
oBrw:aCols[I]:bClrStd := {|| {CLR_BLUE, If( DET->SDETAIL, CLR_YELLOW, CLR_WHITE) } }
NEXT
Regards,
James
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.
I tried this:
At the column browse I did nothing except the same calculation.
Nothing happened.
Need some help. Thanks
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
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
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
Harvey
- Daniel Garcia-Gil
- Posts: 2365
- Joined: Wed Nov 02, 2005 11:46 pm
- Location: Isla de Margarita
- Contact:
try...
Code: Select all | Expand
FOR I = 1 TO LEN(oBrw:aCols)
oBrw:aCols[I]:bClrStd := {|| If( nVara-nVarb, {CLR_BLUE, CLR_YELLOW}, {CLR_BLUE, CLR_WHITE } ) }
NEXT
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
-
- Posts: 989
- Joined: Thu Nov 24, 2005 3:01 pm
- Location: Madrid, España
hag wrote:I tried this:Code: Select all | Expand
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
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
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:
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):
Regards,
James
Code: Select all | Expand
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
oBrw:aCols[I]:bClrStd := {|| {CLR_BLUE, If( val(eval(oBrw:aCols[i]:bStrData))>500 , CLR_YELLOW, CLR_WHITE) } }
Regards,
James
Cell-Color
Hello James,
What happens after Col-swapping ?
I think, it has to be a function.
Regards
Uwe
What happens after Col-swapping ?
I think, it has to be a function.


Regards
Uwe

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.
i work with FW.
If you have any questions about special functions, maybe i can help.
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Uwe,
Good point. It would be better to define it when defining the column.
James
Good point. It would be better to define it when defining the column.
Code: Select all | Expand
oCol:bClrStd := {|| {CLR_BLUE, If( val(eval(oCol:bStrData))>500 , CLR_YELLOW, CLR_WHITE) } }
James
Thanks all Still having problems:
It colors the row perfectly with this code:
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?
It colors the row perfectly with this code:
Code: Select all | Expand
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
Harvey
- Daniel Garcia-Gil
- Posts: 2365
- Joined: Wed Nov 02, 2005 11:46 pm
- Location: Isla de Margarita
- Contact:
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) } }
sorry my english
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) } }

sorry my english

our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Cell-Color
Cell-color for a certain field-value :
[code]
DEFINE BRUSH oBrush1 STYLE "BRICKS"
oCol:oBrush := { || IIF( _FIELD->LAST = "Crystal", oBrush1, NIL ) }
*oCol:bClrStd := { || IIF( _FIELD->LAST = "Crystal", { 16777215,128 }, { 16777215, 6534803 } ) }
Regards
Uwe

Code: Select all | Expand
#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 } ) }

Regards
Uwe

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.
i work with FW.
If you have any questions about special functions, maybe i can help.
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?
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
Harvey
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact: