Delphi DBgrid Wrap Word Content

5.7k Views Asked by At

Is it possible to Word Wrap DBgrid Cell (height) in Delphi (xe) ? I have a dbgrid with multiple columns with a fixed Column width and some columuns has up to 100char and I need them to fit the appropriate Cell without changing the Column width.

Any clue how to do it ?

Thanks.

1

There are 1 best solutions below

0
On

You'll need to make it ownerdraw, and in the OnDrawCell event put the code to fill in the cells:

procedure TForm4.Grid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);  
begin
Grid1.Canvas.TextRect(Rect, Rect.Left+1, Rect.Top+1, WrapText(Grid1.Cells[ACol,ARow], 40));
end;