procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
Const //define your color here. Of course you
//can use default colors too.
clPaleGreen = TColor($CCFFCC);
clPaleRed = TColor($CCCCFF);
//Does the cell have the focus you have to paint it with other colors
if (gdFocused in State) then begin
StringGrid1.Canvas.Brush.Color := clBlack;
StringGrid1.Canvas.Font.Color := clWhite;
else //Does the cell have NOT the focus you can use
//your personal colors here
if ACol = 2 //the second Column should be
//green, the other cells red
then StringGrid1.Canvas.Brush.color := clPaleGreen
else StringGrid1.canvas.brush.Color := clPaleRed;
//Now Paint the cells, but only, if the cell isn't the Title- Row/Column
//This of course depends whether you have title-Row/Columns or not.
If (ACol 0) and (ARow0) then
//Painting the Background
//Painting the Text. Here you can improve the code with
// using alignment and so on.
A portal that has dedication and concentration in the development of computer programming and more
resource for help people such as open project, jobs, question & answer, additional tools, and many more.
Collection of various kinds of code programming language from desktop to web programming.