Author: Tomas Rutkauskas
How to change fonts between columns in a TStringGrid
Answer:
You must write the text to the canvas after setting the font. Use Canvas.TextRect
for this:
1 2 procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
3 Rect: TRect; State: TGridDrawState);
4 begin5 with Sender as TStringGrid do6 begin7 case aCol of8 0: canvas.font.name := 'Courier New';
9 1..5: canvas.font.name := 'Arial';
10 end;
11 Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
12 end;
13 end;