假设第2,4列右对齐,其他的左对齐
procedure TForm1.StringGrid1DrawCell(Sender: TObject;
ACol, ARow: Integer;
Rect: TRect;
State: TGridDrawState);
var
Area: TRect;
begin
with StringGrid1, StringGrid1.Canvas do
begin
FillRect(Rect);
Area:= Rect;
InflateRect(Area, -2, -2);
if (ACol=1) or (ACol=3) then
DrawText(Handle, PChar(Cells[ACol, ARow]),
Length(Cells[ACol, ARow]), Area, DT_RIGHT)
else
TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end;
end;