Location of colored cell:
private ColorCol, ColorRow: integer;
Set colored cell column and row with Button1, and force stringgrid to repaint:
procedure TForm1.Button1Click(Sender: TObject); begin ColorCol := Col; ColorRow := Row; StringGrid1.Repaint; end;
Color delphi stringgrid cell in OnDrawCell event handler:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;Rect: TRect; State: TGridDrawState); var S: string; begin if (ACol = ColorCol) and (ARow = ColorRow) then begin StringGrid1.Canvas.Brush.Color := clYellow; StringGrid1.Canvas.FillRect(Rect); S := StringGrid1.Cells[ACol, ARow]; StringGrid1.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, S); end; end;











