Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid control dynamic colours

Status
Not open for further replies.

wadesnj

Programmer
Mar 24, 2001
36
Can I make alternate lines of a grid control different colours? I have seen an example using odd and even values in a field, but I want to do it without using the actual data from the table, just alternate lines of the grid.
 
Use recno() like this :

MyGrid.SetAll("DynamicBackColor", "IIF(recno()%2=0, RGB(253,254,240),RGB(255,255,255))", "Column")

Cheers,
Jamie
 
Obviously if the recordsource is indexed, then an expression like recno()probably won't work. Unfortunately the only way you can set the dynamicbackcolor to change, is to use some expression that can be computationally evaluated and "every other record" won't do it. You'll have to provide some data to allow the evaluation to provide your alternate coloring scheme. (In other words "there ain't no magic here".)

Rick
 
Hi!

This topic was discussed many times here and at the UT, and conclusion was to use only additional column with order number of record. After changing the order (index), recalculate the order using pure scan/replace. Than use value of that field for lines coloring.
Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Hi Vlad.. Sorry..

Hi Wadesnj, it is possible to have alternative rows in alternative colors...

In the Init Event of the Grid... put the code...
******************************************************
DODEFAULT()
WITH THIS
&& Set the alternative Rows in different colours
.SetAll("DynamicBackColor", ;
"IIF(MOD(This.ACTIVEROW,2)=0,RGB(255,255,192),RGB(128,255,255))", ;
"COLUMN")
ENDWITH
**End
*******************************************************
This will make the alternative rows in different colors.

Sorry, I am too busy in my project and last 10 days I havnt contributed anything.

Hope this helps
Ramani ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
ramani, this will work only when grid is actoivated and not scrolled vertically by such way that current row is outside of the visible area. When grid is not focused or it is scrolled out from current record, ActiveRow property is always zero and thus it is useless for coloring in the approach you posted.
Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top