在OnDrawCell中加入如下代码:
procedure TForm1.Stringgrid1DrawCell(Sender: TObject;
ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
with Sender as TStringGrid do
begin
Canvas.FillRect(Rect);
DrawText(Canvas.Handle, Pchar(Cells[ACol, ARow]),
Length(Cells[ACol, ARow]), Rect,
DT_CENTER or DT_SINGLELINE or DT_VCENTER);
end;
end;
本文来自博客园,作者:del88,转载请注明原文链接:https://www.cnblogs.com/del88/archive/2011/12/29/2305734.html