Im OnDrawCell. Beispiel aus einem meiner Projekte:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
| procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin with (Sender as TStringGrid) do begin if BP[ARow] then begin Canvas.Brush.Color:=clRed; Canvas.Font.Color:=clWhite; if Selection.Top = ARow then Canvas.Brush.Color:=clBlue; end else begin Canvas.Brush.Color:=clWhite; Canvas.Font.Color:=clBlack; if Selection.Top = ARow then begin Canvas.Brush.Color:=clHighlight; Canvas.Font.Color:=clWhite; end; end; if ACol = 1 then Canvas.Font.Style:=[fsBold] else Canvas.Font.Style:=[]; Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+2,Cells[ACol,ARow]); Canvas.FrameRect(Rect); end; end; |
Hebt in einem dreispaltigen Grid Quelltext hervor (Breakpoints rot markiert, mittlere Spalte fett).
Probier maln bisschen rum.
Gruß,
Jörg