• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1536
  • Last Modified:

DBgrid rowcolors

i have a tms DBadvgrid and i show some records of my table to the dbgrid.I want to paint with diffrent color the rows that is even and with different cooor the rows that is odd for example i want the first row to have red color and the 2nd row to have green,the 3rd to have the same color with the first and the 4rth with the second row (even and odd rows...) or you can suggest me other ways to do this.

Thanks in advance.
0
Alex
Asked:
Alex
1 Solution
 
Tomas Helgi JohannssonCommented:
0
 
mikelittlewoodCommented:
For the TMS component use the OnGetCellColor event of the component

procedure TForm1.DBAdvGrid1GetCellColor( sender: TObject; ARow,
   ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
   // ignore header
   if ARow > 0 then
   begin
      case ARow mod 2 of
         0: ABrush.color := clRed;
         1: ABrush.color := clBlue;
      end;
   end;
end;
0
 
AlexSoftware EngineerAuthor Commented:
thanks a lot... you are great!!! i 'll need you more if you know good the tms grid... ;)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now