Du setzt den Style auf OwnerDraw, und nutzt dann das OnDrawCell-Ereignis, um den Text manuell zu zentrieren:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
| procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var a : Integer; begin with (Sender as TStringGrid) do begin a:=(Rect.Right-Rect.Left-Canvas.TextWidth(Cells[ACol,ARow])) div 2; Canvas.TextRect(Rect,Rect.Left+a,Rect.Top+2,Cells[ACol,ARow]); Canvas.FrameRect(Rect); end; end; |
Ungetestet. Aber so in etwa ...
Gruß,
Jörg