Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing color of changed cells
Message
De
16/09/1998 05:08:32
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00136971
Message ID:
00137172
Vues:
17
>Somebody told me once how to make cells in a grid that have changed be a different color, but I cannot find where I wrote that down.
>
>This is what I tried:
>
>
>FOR i = 1 TO THIS.columncount
>   THIS.COLUMNS[i].dynamicforecolor = ;
>      "IIF CURVAL(EVAL(THIS.controlsource)) <> OLDVAL(EVAL(THIS.controlsource)), ;
>       RGB(255,0,0), RGB(0,0,0))"
>ENDFOR
>
>
>
>I also tried it without the EVAL, and with an & instead. It doesn't give an error; it just doesn't work.
>
>As I'm typing this, I just got a clue. I'm using a view, so the controlsource is a field in the view, not the table. Is that why?
>
>How do I make this work with a view?
>
>Thanks,
>
>-Michelle
Hi Michelle,
If you got that during a UT chat then that "somebody" might be me. Original code is :
*Grid.init
for ix = 1 to this.columncount
 with this.columns(ix)
	cField = substr(.controlsource,rat(".",.controlsource)+1)
	cAlias = substr(.controlsource,1,rat(".",.controlsource)-1)
	.DynamicBackColor =	"iif(oldval([" + ;
				cField+"],["+cAlias+"])#"+;
				.controlsource+;
				" or recno(["+cAlias+"])<0,"+;
				str(rgb(255,0,0))+","+str(this.backcolor)+")"
	endwith
endfor
I prefer this style vs setall (just preference and this one works all the time). Payoff is some local variables and a loop, but just done once in init, so I don't think it could be thought as a performance penalty.
Caution : Assumes nulls are not accepted, otherwise oldval() # val comparison generates error and should be extended to control with isnull().
PS : With the addition of a timer + custom property (blinkon) you could even make the color "blink".
And another extension could be made oldval() vs curval() for potential update conflict coloring.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform