code for stringgrid alternating colours

Posted by Wiona on October 10, 2008

In Reply to delphi stringgrid alternating colours posted by Al Peterson on October 08, 2008

: : how can I give alternate background colors to the rows of a stringgrid? for example, colour the even rows in yellow, but leave the fixed row with the titles? (there is no fixed column). like this:

: : title row 0 - normal (silver)
: : data row 1 - normal (white)
: : data row 2 - yellow
: : data row 3 - normal (white)
: : data row 4 - yellow
: : and so on

: Conditions:
: Even numbered rows: Row mod 2 = 0
: Not title row: Row 0
: Conditions when to change the background colour:
: if (Row mod 0 = 0) and (Row 0) then
: begin
: Brush.Color := Somecolour;
: // Paint rectangle of cell Col,Row with Brush.Color;
: // Write text of cell Col,Row over this background
: end;

Thanks for your answer, but please can you give me some real source code example? Sorry, I don't understand how to use your answer in my code.

Related articles

       

Follow Ups