Author: Tomas Rutkauskas
How can I code the Fixed Row in Bold (font) style whereas Normal Rows in Normal
style for TStringGrid component?
Answer:
You need to handle the OnDrawCell event.
1 2 procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
3 Rect: TRect; State: TGridDrawState);
4 var5 Fmt: integer;
6 begin7 StringGrid1.Canvas.FillRect(Rect);
8 {set bold for fixed cells, also set alignment}9 if gdFixed in State then10 begin11 StringGrid1.Canvas.Font.Style := [fsBold];
12 Fmt := DT_SINGLELINE or DT_VCENTER or DT_CENTER;
13 end14 else15 Fmt := DT_SINGLELINE or DT_VCENTER or DT_LEFT;
16 DrawText(StringGrid1.Canvas.Handle, PChar(StringGrid1.Cells[ACol, ARow]), -1,
17 Rect,
18 Fmt);
19 end;