• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1583
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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