Board index » delphi » cell by cell fonts properties in TStringGrid?

cell by cell fonts properties in TStringGrid?

Can I set italics in a TStringGrid in a specific cell?

I just got asked by another programmer in the office, and suggested
doing it through the canvas, but it didn't work.

His app is a legacy piece on Delphi 1.

Thanks,

William Meyer

 

Re:cell by cell fonts properties in TStringGrid?


It worked for me(I'm using Delphi4, but assuming that it should work in
Delphi1 too)

procedure TForm3.stringgrid1DrawCell(Sender: TObject; ACol, ARow:
Integer;  Rect: TRect; State: TGridDrawState);
begin
  if (acol = 2) and (Arow = 5)then//there is your cell coordinates
  begin
    stringgrid1.Canvas.Font.style := stringgrid1.canvas.font.style +
[fsitalic];
    stringgrid1.canvas.fillrect(Rect);//clean old text
    stringgrid1.canvas.TextOut(rect.left, rect.top,
stringgrid1.cells[acol, arow]);
  end;
end;

Quote
William Meyer wrote:
> Can I set italics in a TStringGrid in a specific cell?

> I just got asked by another programmer in the office, and suggested
> doing it through the canvas, but it didn't work.

> His app is a legacy piece on Delphi 1.

> Thanks,

> William Meyer

Re:cell by cell fonts properties in TStringGrid?


Quote
Alexandra wrote:

> It worked for me(I'm using Delphi4, but assuming that it should work in
> Delphi1 too)

thank you! I've passed it on.

William Meyer

Other Threads