Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Still trying to set different colors for fields in a gri
Message
De
24/10/2013 08:18:24
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01586262
Message ID:
01586286
Vues:
111
>I'm still trying to figure out a way to make each cell on a grid row possibly have a different color.
>i.e. field one of the grid on the first row(record) will be blue, the second field on the first row(record) will be green.
>BUT
> field one of the grid on the second row(record) will be green, the second field on the second row(record) will be blue.
>
>these colors would be determine by the value of the field ie field1 = 'C' color = blue but if field1 = 'B' color = green
>
>Is there anyway to accomplish this?

Only with dynamic colors. Beware that whatever you set as a dynamic color which is evaluated (yep, using equivalent of eval()) in the context of the column (or grid - check, I can't remember which one is it if you mention this.something) and the current row of grid's .recordsource alias. The more complicated the expression, the longer it will take. Each dynamic property is evaluated for each cell on each .refresh() of the grid, which may be firing more frequently than you think.

In my experience, the simplest expression in dynamic color properties is an integer; an integer being a constant doesn't do much for the dynamics, but then the next best speed comes from an integer field. So for each column where you want the color to be dynamic, add an integer column where you'd store the color. Set the alias.name of that integer column as the dynamic color expression, and then have some code somewhere which will calculate these colors for each column whenever a value of a field changes. Which will then be calculated only when it changes, not on every refresh, and will be quite fast.

So...
replace all iColor1 with iif(field1="C", rgb(0,0, 255), 0)
and so on for each column. Then column1.dynamicforecolor="alias.iColor1", etc. The added bonus, if you'd consider it one, is that all the color coding is in one piece of code, instead of being scattered through PEM windows of each column, in those tiny textboxes of insufficient size.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform