Voici la réponse :
procedure TForm1.FormCreate(Sender: TObject);
begin
//juste pour indiquer comment paramètrer le TStringGrid
with StringGrid1 do
begin
Options := Options + [goDrawFocusSelected];
DefaultDrawing := True;
end;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
sWidth : integer;
begin
with StringGrid1 do
//ne pas cadrer les titres
if not (gdFixed in state)then
begin
Canvas.FillRect(Rect);
sWidth := Canvas.TextWidth(Cells[ACol, ARow]) + 2;
Canvas.TextOut(Rect.Right - sWidth, Rect.Top + 2, Cells[ACol, ARow]);
end;
StringGrid1.DefaultDrawing := True;
end;
En résumé, il suffit de déterminer la position de début d'écriture de la chaîne de caractères.
May Delphi be with you