You are on page 1of 11

DynamicBackColor = "IIF(tmptable.

average,colorthreshold(),RGB(255,255,255))"

THISFORM.Grid1.Columns(6).DYNAMICBACKCOLOR = "IIF(RECNO('tablename')= 2,RGB(255,0,0),RGB(255,255,255))"

THISFORM.Grid1.SETALL("DYNAMICBACKCOLOR", ;
                       "IIF(Patlist2.Note_2_file =.T.,RGB(0,255,0), ;
                       IIF(Patlist2.Pat_closed = .T.,RGB(255,0,0), ;
                       RGB(255,255,255))))", ;
                      "Column")

* oGrd = thisform.grid11

*!* *!* * Clear the current grid dynamic fore and back colors
*!* *----------------------------------------------------
*!* oGrd.SetAll("dynamicbackcolor", "", "Column")
*!* oGrd.SetAll("dynamicforecolor", "", "Column")

*!* *----------------------------------------------------
*!* oGrd.SetAll("dynamicforecolor", ;
*!* "IIF(PCURASCH.AFF_LEAVE='NO', RGB(255,255,255), RGB(0,0,0))", "Column")
*!* oGrd.SetAll("dynamicbackcolor", ;
*!* "IIF(PCURASCH.AFF_LEAVE='NO', RGB(192,192,192), RGB(255,255,255))", "Column")
*!* *----------------------------------------------------
*!* oGrd.Refresh

!* *----------------------------------------------------
*!* oGrd.SetAll("dynamicforecolor", ;
*!* "IIF(PCURASCH.AFF_LEAVE='YES-REC', RGB(), RGB()", "Column")
*!* oGrd.SetAll("dynamicbackcolor", ;
*!* "IIF(PCURASCH.AFF_LEAVE='YES-REC', RGB(), RGB())", "Column")
*!* *----------------------------------------------------

oGrid.SetAll( 'DynamicBackColor', ;

"IIF( PCURASCH.AFF_LEAVE='NO', RGB(192,192,192), IIF( PCURASCH.AFF_LEAVE='YES-REC',


RGB(204,204,255),RGB(255,255,255) ) )" )

Set grid dynamic fore and back colors for discontinue & expired items
*----------------------------------------------------------------------
oGrd.SetAll("dynamicforecolor", ;
"IIF(upper(tag_edb) = 'ED', RGB(255,255,255), IIF(empty(alltrim(tag_edb))) ,RGB(0,0,0),RGB(0,0,0)))","Column")
oGrd.SetAll("dynamicbackcolor", ;
"IIF(upper(tag_edb) = 'ED', RGB(255,0,0), IIF(empty(alltrim(tag_edb)))
,RGB(255,255,128),RGB(255,255,255)))","Column")

oGrd.Refresh

oGrd = This.grdInven
>
> * Clear the current grid dynamic fore and back colors
> *----------------------------------------------------
> oGrd.SetAll("dynamicbackcolor", "", "Column")
> oGrd.SetAll("dynamicforecolor", "", "Column")
>
>
> ** This section works fine
>
>
> * Set grid dynamic fore and back colors for expired items
> * -------------------------------------------------------
> oGrd.SetAll("dynamicforecolor", ;
> "IIF(upper(tag_edb) = 'E', RGB(255,255,255), IIF(upper(tag_edb)='D',RGB(0,0,0),RGB(0,0,0)))","Column")
> oGrd.SetAll("dynamicbackcolor", ;
> "IIF(upper(tag_edb) = 'E', RGB(0,64,128),IIF(upper(tag_edb)='D',RGB(255,255,128),RGB(255,255,255)))","Column")
>
>
>

oGrd.SetAll("dynamicforecolor", ;

"IIF(UPPER(ALLTRIM(tag_edb)) = 'ED' or UPPER(ALLTRIM(tag_edb)) = 'E', RGB(255,255,255),


RGB(0,0,0))","Column")

oGrd.SetAll("dynamicbackcolor", ;

"ICASE(UPPER(ALLTRIM(tag_edb)) = 'ED', RGB(255,0,0), UPPER(ALLTRIM(tag_edb)) = 'E', RGB(0,64,128),"+;

"EMPTY(tag_edb) or ALLTRIM(UPPER(tag_edb)) = 'D',RGB(255,255,128),RGB(255,255,255))","Column")

 > oGrd.SetAll("dynamicforecolor", ;
> > "IIF(upper(tag_edb) = 'E', RGB(255,255,255), IIF(upper(tag_edb)='D',RGB(0,0,0),RGB(0,0,0)))","Column")
> > oGrd.SetAll("dynamicbackcolor", ;
> > "IIF(upper(tag_edb) = 'E', RGB(0,64,128),IIF(upper(tag_edb)='D',RGB(255,255,128),RGB(255,255,255)))","Column")
>>
>>
>>
> > ** This section causes the problem
>>
>>
> > * Set grid dynamic fore and back colors for discontinue & expired items
> > *----------------------------------------------------------------------
> > oGrd.SetAll("dynamicforecolor", ;
> > "IIF(upper(tag_edb) = 'ED', RGB(255,255,255), IIF(empty(alltrim(tag_edb))) ,RGB(0,0,0),RGB(0,0,0)))","Column")
> > oGrd.SetAll("dynamicbackcolor", ;
> > "IIF(upper(tag_edb) = 'ED', RGB(255,0,0), IIF(empty(alltrim(tag_edb)))
,RGB(255,255,128),RGB(255,255,255)))","Column")
>>
> > oGrd.Refresh
>>
>>
> > Thank you very much guys & ladies
>>
> > Patrick
>
> Are all those conditions in just one grid? If so, better combine those in one SetAll:
>
>

oGrd.SetAll("dynamicforecolor", ;

> "IIF(UPPER(ALLTRIM(tag_edb)) = 'ED' or UPPER(ALLTRIM(tag_edb)) = 'E', RGB(255,255,255),


RGB(0,0,0))","Column")

> oGrd.SetAll("dynamicbackcolor", ;

> "ICASE(UPPER(ALLTRIM(tag_edb)) = 'ED', RGB(255,0,0), UPPER(ALLTRIM(tag_edb)) = 'E', RGB(0,64,128),"+;


> "EMPTY(tag_edb) or ALLTRIM(UPPER(tag_edb)) = 'D',RGB(255,255,128),RGB(255,255,255))","Column")

>

>

I've always used the following type of statement to achieve alternate row background colors in a grid :
myGrid.SetAll("DynamicBackColor", "IIF(recno()%2=0, RGB(blah),RGB(blah))", "Column")

I've been using the following in my Grid.Refresh for a whil to alternate line background colors in my grids:

This.Setall("DynamicBackColor", "IIF(MOD(Recno(), 2) = 0, white, green", "Column")

I would like to alternate row background colors in a grid that is NOT dependent on the RECNO() function. Taken from the
VFP Help:

THISFORM.MyGrid.SETALL("DynamicBackColor", ;

"IIF(MOD(RECNO(), 2)=0, RGB(255,255,255), RGB(190,190,190))", ;

"Column")

procedure grid1.init

with thisform.grid1

.recordsource = 'out1'

.visible = .t.

.setall("dynamicbackcolor", ;

"iif(MOD(RECNO('out1'),2)=0, RGB(0,255,0),rgb(255,255,255))","column")

.refresh

endwith

endproc

**************8

oGrd.SetAll("dynamicbackcolor", ;

[IIF( (plancost - planpay <> 0) and (plancost + planpay <> cost),]+;

[RGB(255,0,0),]+;

[RGB(255,255,255))]+;

, "Column")
88888***************************************************

hi
i have a trouble
i want to give some color in grid with 4 condition

if
stt=sta01 --> green
stt=sta02 --> yellow
stt=sta03 --> purple
stt=sta04 --> red

i was try like this :


thisform.grid1.SetAll("DynamicBackColor", "iif(stt=sta01,RGB(0,255,0),(stt =sta02,RGB(255,255,103),(stt
=sta03,RGB(204,51,0), (stt=sta04 ,RGB(204,0,204)))))", "Column")

but the color is not shown

********************************************************

I have this grid as you can see, in the below code and besides that i am highlighting the whole record for the condition
exposed in the code, also would like to highlight two columns, those are QTYORD AND QTYREC.

also wouldl like to know if can select the column ItemNo and be able to open a txtbox there, to search for an specific
value under that column and refresh the grid and move to that record in the grid ?

Select ball_no, Sheet, QTYORD, QTYREC, PRC, ItemNo, vendorpartno, ;

descrip, Recdate, purno;

From RESULS1 ORDER BY 1 INTO Cursor RESULS2

If _Tally > 0

With Thisform.grid2

.Visible = .T.

.ColumnCount = -1

.RecordSource = 'resuls2'

.Refresh()

.Setall("DynamicBackColor", "IIF(resuls2.qtyord = resuls2.qtyrec, RGB(255,255, 0), 0xFFFFFF)") 0 yellow

.Column3.DynamicForeColor= "IIF(resuls2.qtyord= resuls2.qtyrec, RGB(255,0,0),RGB(0,0,0))"

.Column4.DynamicForeColor= "IIF(resuls2.qtyord= resuls2.qtyrec, RGB(255,0,0),RGB(0,0,0))"

ENDWITH

I know i am asking two question in one, please help, as you can.

i need these columns to be coloring in Red


are these lines below correct to obtain those columns colored if the condition is true ?

.Column3.DynamicForeColor= "IIF(resuls2.qtyord= resuls2.qtyrec, RGB(255,0,0),RGB(0,0,0))"


.Column4.DynamicForeColor= "IIF(resuls2.qtyord= resuls2.qtyrec, RGB(255,0,0),RGB(0,0,0))"

Thanks in advance

**********************************************8

 I read the whole world about how to colour cells in a VFP grid.
> Came across solutions colouring rows. Came across that calendar example.
> Came across those add method add property examples that don't work.
>
> Now to make it easy, my way: (No classes, no methods, no properties aditional)
> in VFP9
>
> * example grid with 29 columns, donald1 to donald29, testing values 1 to 5
> FOR l=2 TO 29
> var1="donald"+ALLTRIM(STR(l-1))
> thisform.grid1.columns(l).dynamicbackcolor="icase(&var1=1, rgb(255,0,0), ;
> &var1=2, rgb(0,255,0),;
> &var1=3, rgb(0,0,255),;
> &var1=4, rgb(255,255,0),;
> &var1=5, rgb(255,0,255),;
> rgb(255,255,255) )"
> endfor
> ** do not use iff() goes very wrong
>
> Stick it some where in you form under a button or so. You are invited to experiment further. Beats the heck out of
Excel, doesn't it? Now still lacks a grid that can
> show records vertically. No, not that crummy excel pivot feauture. Pure VFP!!!

FOR l=2 TO 29

var1 = "m.donald"+ALLTRIM(STR(l-1)) && I hope these variables (donald1 to donald28) are accessible everywhere

TEXT TO thisform.grid1.columns(l).DynamicBackColor NOSHOW TEXTMERGE PRETEXT 15

icase(<<var1>> = 1, rgb(255, 0, 0),

<<var1>> = 2, rgb( 0,255, 0),

<<var1>> = 3, rgb( 0, 0,255),

<<var1>> = 4, rgb(255,255, 0),

<<var1>> = 5, rgb(255, 0,255),

rgb(255,255,255) )

ENDTEXT

endfor

******************************************

How do you bolden and assign the font size in the dynamic realm of the grid, in the following
program :
oGrd =THISFORM.PAGEFRAME1.PAGE3.GRID1

*!* * Clear the current grid dynamic fore and back colors

*----------------------------------------------------

oGrd.SetAll("dynamicbackcolor", "", "Column")

oGrd.SetAll("dynamicforecolor", "", "Column")

*----------------------------------------------------

oGrd.SetAll("dynamicFontBold", ;

"IIF(WAPPR_HOLD.ANUWAGSAL>0.00, RGB(255,255,255), RGB(0,0,0))", "Column")

**********************************88

 have this in the INIT of my form and it works great. I also would like a checkbox (Column6 of the grid) to either become
invisible or have the background color the same as the background color of the row it is on for a certain condition.
Basically, I do not want to show the checkbox for records where the Status has the word "Lawyer" in it.

THISFORM.Grid1.SetAll("DynamicBackColor", "IIF(AT('LAWYER',UPPER(Lawyer_Cursor.Status))>0, RGB(255,125,125),


IIF(AT('CLIENT',UPPER(Lawyer_Cursor.Status))>0, RGB(255,240,140), RGB(255,255,255)))")

********************88

 I Wonder if, i'm used this command in the correct form!


>
> THISFORM.Grid1.SETALL("DynamicBackColor", ;
> "IIF(Red_Status=.T., RGB(255,0,0)),IIF(Org_Status=.T., RGB(255,128,0)),IIF(Grn_Status=.T., RGB(0,255,64));
> , RGB(219,224,158)", "COLUMN")
>
>
> i wish 3 dynamicbackcolor in my grid!!! Red,Orange and Green if the status is true!
>
> Thanks advance!

Nope, you have too many closing brackets

THISFORM.Grid1.SETALL("DynamicBackColor", ;

"IIF(Red_Status, RGB(255,0,0) ,"+;

"IIF(Org_Status, RGB(255,128,0),"+;

"IIF(Grn_Status, RGB(0,255,64) ,"+;

RGB(219,224,158))))", "COLUMN")

****************************************************Borislav Borissov

Is there any feature available in listbox like grid which has several columns as follows:

With ThisForm.Grid1
.
.
.
.SetAll("dynamicbackcolor", "IIF(RECNO()%2 = 0,RGB(178,194,119), RGB(255,255,255))", "Column")
.
.
.
endwith

Thanks

*****************************************8

Hi all,

I got an error saying "unrecoqnized command verb" when I use this syntax below. I notice that actually because the
syntax is more than 255 char. Please advise how should I do.

Thisform.grdlcsrch.SetAll("DynamicBackColor", ;

"IIF(TRIM(tmpLpsd.notes)='YELLOW',RGB(247,247,171),IIF(TRIM(tmpLpsd.notes)='BLUE',RGB(214,216,250),IIF(TRIM(tmp
Lpsd.notes)='GREEN',;

RGB(214,250,214),IIF(TRIM(tmpLpsd.notes)='RED',RGB(255,224,193),IIF(TRIM(tmpLpsd.notes)='BROWN',RGB(207,159,1
11),THIS.Column1.BackColor)))))", "Column")

************************************

 Hi all,
>
> I got an error saying "unrecoqnized command verb" when I use this syntax below. I notice that actually because the
syntax is more than 255 char. Please advise how should I do.
>
>

Thisform.grdlcsrch.SetAll("DynamicBackColor", ;

>
"IIF(TRIM(tmpLpsd.notes)='YELLOW',RGB(247,247,171),IIF(TRIM(tmpLpsd.notes)='BLUE',RGB(214,216,250),IIF(TRIM(tmp
Lpsd.notes)='GREEN',;

>
RGB(214,250,214),IIF(TRIM(tmpLpsd.notes)='RED',RGB(255,224,193),IIF(TRIM(tmpLpsd.notes)='BROWN',RGB(207,159,1
11),THIS.Column1.BackColor)))))", "Column")

>
> Thanks
> Ursula

*********************************************

If SEEK(ALLTRIM(thisform.text1.value), 'cCurItem', 'itemName')


.gridItem.SETALL("DynamicBackColor", ;
"IIF(RECNO('cCurDebtor') = thisform.lnRow, RGB(189,190,230), " + ;
"iif('" + alltrim(thisform.text1.value) + ;
"' & alltrim(cCurItem.itemName), iif(empty('" + thisform.text1.value + "'), RGB(255,255,255), RGB(230,243,255)), " + ;
"RGB(255,255,255)))", "Column")
.gridItem.SETALL("DynamicForeColor", ;
"IIF(RECNO('cCurItem') = thisform.lnRow, RGB(255,255,255), RGB(0,0,0))", ;
"Column")
.gridItem.REFRESH
.gridItem.SETFOCUS
This.SETFOCUS
Endif

Thanks

**********************************888

Dynamic* requires valid expressions. Yours is not valid. You have a missing comma in IIF(). You didn't really need to use
& in a dynamic setting and it would b much better if you use m.

PS: Not sure your expression looks like to be:

.SetAll("dynamicforecolor", ;

TEXTMERGE('(IIF(ALLTRIM(<<m.lcOwnerViewField>>) == ALLTRIM(m.pcVwUserUsrid_u),'+;

' <<m.lcFCol1>>,<<m.lcFCol2>>))') )

***********************888

i
How can set both "DynamicFontBold" & DynamicForeColor together in a grid if the cell contain negative value
How to simplify below codes which is currently using.

.column1.DynamicBackColor="IIF(short01<0,RGB(255,115,117),RGB(113,255,113))"

.column2.DynamicBackColor="IIF(short02<0,RGB(255,115,117),RGB(113,255,113))"

.column1.DynamicFontBold="IIF(short01<0,.T.,.F.)"

.column2.DynamicFontBold="IIF(short02<0,.T.,.F.)"

.column1.DynamicForeColor="IIF(short01<0,RGB(255,255,255),RGB(0,0,0))"

.column2.DynamicForeColor="IIF(short02<0,RGB(255,255,255),RGB(0,0,0))"

********************88

I have DynamicForeColor and DynamicBackColor being used in a grid with the SETALL() function. I was tasked with
putting a command button in the last column of the grid in order to display the contents of a Memo Field in a Modal
Form. It appears that my desire to not have the BackColor and ForeColor override the button's colors so far has been
thwarted. How can I leave the row colors with SETALL() in place but also have my one Command button remain with its
original BackColor and ForeColor and thus not be washed out? If it were a CommandGroup, it would work, but it is only
a Command button. Is there some way around this?

WITH THISFORM.pageframe1.page1.grdToDoList

.SETALL("DynamicBackColor", ;

"ICASE(follow_up > DATE(),RGB(255,255,255),follow_up = DATE(),RGB(255,255,0),follow_up <


DATE(),RGB(255,0,0))", "Column")

.SETALL("DynamicForeColor", ;

"ICASE(follow_up > DATE(),RGB(0,0,0),follow_up = DATE(),RGB(0,0,0),follow_up <


DATE(),RGB(255,255,255))", "Column")
.SETALL("DynamicBackColor", RGB(212,208,200), "Command") && Won't work. Original Command button
BackColor.

.SETALL("DynamicForeColor", RGB(0,0,0), "Command") && Won't work. Original Command button


ForeColor.

ENDWITH

Thanks,

Cecil

**************************************************

Thisform.nCurrRec = RECNO()

THis.setall("DynamicForeColor", "IIF( Recno()=thisform.nCurrRec,RGB(255,255,255),RGB(0,0,0))", "COLUMN")

This.setall("DynamicBackColor", "IIF( Recno()=thisform.nCurrRec,RGB(0,0,255),RGB(255,255,255))", "COLUMN")

This.Refresh()

**************************************************************

can you help me with my problem.. i have a customer table which is index on names
i'm using the grid to show the record of my table..
i have also a textbox, i used this for searching the record of my table..
when the user enter a single letter in the textbox it will search records in the table
with the letter beggining of what the user has entered and at the same time the grid will
highlight to the found records..

my code goes like this.. (this is under textbox interactivechange method)


R=0
SELECT client
GO TOP
locate for upper(name1) = ALLTRIM(THIS.VALUE)
IF FOUND()
RECNO(R)
THISFORM.GRID2.SetAll("dynamicforecolor","IIF(RECNO()=R, RGB(255,255,255), RGB(0,0,0))", "Column")
THISFORM.GRID2.SetAll("dynamicbackcolor","IIF(RECNO()=R, RGB(255,0,0), RGB(255,255,255))", "Column")
ENDIF

works well but my problem is its response to the what the user entered in the textbox.. it is very slow
can anyone help me make it fast? or do i have to put the code in keypress event? pls help..
thanks in advance...

*****************************************************

 Hey Folks
> I have the following code in the init event of a grid
>

this.column4.DynamicBackColor = iif(thegrosspayroll.hrmin==.t.,"rgb(0,205,0)","rgb(255,255,255)")

> and it shows the green color for the entire column4 but what I and trying to get done is that it only shows green for
the records that have

thegrosspayroll.hrmin==.t.
> nb thegrosspayroll is the backing cursor for the grid...
>
> Thanks in advance
> Chris Smith

Set this in the Init of form:

oGrd.SetAll("dynamicforecolor", ;

"ICASE(thegrosspayroll.hrmin==.t., RGB(255,255,255), RGB(0,0,0))","Column")

oGrd.SetAll("dynamicbackcolor", ;

"ICASE(thegrosspayroll.hrmin==.t., RGB(0,205,0), RGB(255,255,255))","Column")

*****************************

I read the whole world about how to colour cells in a VFP grid.
Came across solutions colouring rows. Came across that calendar example.
Came across those add method add property examples that don't work.

Now to make it easy, my way: (No classes, no methods, no properties aditional)


in VFP9

* example grid with 29 columns, donald1 to donald29, testing values 1 to 5


FOR l=2 TO 29
var1="donald"+ALLTRIM(STR(l-1))
thisform.grid1.columns(l).dynamicbackcolor="icase(&var1=1, rgb(255,0,0), ;
&var1=2, rgb(0,255,0),;
&var1=3, rgb(0,0,255),;
&var1=4, rgb(255,255,0),;
&var1=5, rgb(255,0,255),;
rgb(255,255,255) )"
endfor
** do not use iff() goes very wrong

Stick it some where in you form under a button or so. You are invited to experiment further. Beats the heck out of Excel,
doesn't it? Now still lacks a grid that can
show records vertically. No, not that crummy excel pivot feauture. Pure VFP!!!

ENTIRE THREAD

***********************************

Hi Friend

I have read the thread 130168 by Sudip Ray & reply by Borislav Borissov on Dynamic Back Color

My problem is:

- while working with the Grid setting, when I move from Row to Row, how to have only one entire row displaying the
SAME Dynamic Back Color?
Most of the time, only one particular cells is displayed or when I use the Dynamic Back Color function such as suggested
by Borislav

frmMyForm.grdGrid1.SetAll("DynamicBackColor", ;
[ICASE(--condition1---, RGB(...), ;
--condition2---, RGB(...),;
--condition3---, RGB(...),;
--condition4---, RGB(...),;
--- otherwise RGB(...))],;
"Column")

I will need to have a certain condition to be fulfill before the whole row can display the SAME back color.

For my case, I am moving from row to row, how to set this condition required?? I only want to have one row at a time
(when the row is the active row)

Please provide example.

Thanks in-advance

Ong Kee Tiong


*******************************************

 I have message when i run this query.


> grade filed does not accept null value
>
> update examtran SET Grade = ICASE(BETWEEN(hwsv.Perc, 99,100), '10',;
> BETWEEN(hwsv.Perc, 90,99), '9',;
> BETWEEN(hwsv.Perc, 80,80), '8',;
> BETWEEN(hwsv.Perc, 70,79), '7',;
> BETWEEN(hwsv.Perc, 60,69), '6',;
> BETWEEN(hwsv.Perc, 50,59), '5',;
> BETWEEN(hwsv.Perc, 40,49), '4',;
> BETWEEN(hwsv.Perc, 30,39), '3',;
> BETWEEN(hwsv.Perc, 20,29), '2');
> from examtran;
> INNER JOIN hwsv ON examtran.code = hwsv.code

May be you can use this, I didn't test:

update examtran SET Grade = ;

ICASE(BETWEEN(NVL(hwsv.code,0) , 99,100),'10',LTRIM(STR(INT(NVL(hwsv.code,0) /10))));

from examtran;

INNER JOIN hwsv ON examtran.code = hwsv.code

Regards
Samir

******************************

You might also like