procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col, Row: Integer; Rect: TRect; State: TGridDrawState);
var
TheGrid : TStringGrid;
A : String;
begin
TheGrid := Sender as TStringGrid;
if (Row < TheGrid.FixedRows) or (Col < TheGrid.FixedCols) then
TheGrid.Canvas.Brush.Color := clBtnFace
else
TheGrid.Canvas.Brush.Color := clWhite;
TheGrid.Canvas.FillRect(Rect);
A := TheGrid.Cells[Col,Row];
DrawText( TheGrid.Canvas.Handle,PChar(A),StrLen(PChar(A)),Rect,DT_WORDBREAK);
end;
编辑也差不多吧,
这个行数是随着长度的变化而变的,要不动态的判断,再改宽度??
试一试吧。