2
votes

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
Use ownerdraw, and paint the text OnDrawCelllkobik
@kobik, but you will need to adjust row height as well.TLama
Surely this has been done thousands of times already google.com/search?q=delphi+wrap+dbgridJan Doggen
@kobik: TDbGrid does not have OnDrawCell. It does have OnDrawColumnCellMark Patterson

1 Answers

-1
votes

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;