Hur fixar man så att Använd händelsen OnDrawCell.StringGrind
det går att skriva flera rader i en cell?
Exmp.
+--------------+
| Bilen är blå |
| men mycket|
| rostig |
+--------------+Sv: StringGrind
Koden nedan ger dig en start.
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
S: String;
drawrect :trect;
begin
S:= (Sender As TStringgrid).Cells[ ACol, ARow ];
If Length(S) > 0 Then Begin
drawrect := rect;
DrawText((Sender As TStringgrid).canvas.handle,
Pchar(S), Length(S), drawrect,
dt_calcrect or dt_wordbreak or dt_left );
If (drawrect.bottom - drawrect.top) >
(Sender As TStringgrid).RowHeights[Arow]
Then
(Sender As TStringgrid).RowHeights[Arow] :=
(drawrect.bottom - drawrect.top)
Else Begin
drawrect.Right := rect.right;
(Sender As TStringgrid).canvas.fillrect( drawrect );
DrawText((Sender As TStringgrid).canvas.handle,
Pchar(S), Length(S), drawrect,
dt_wordbreak or dt_left);
End;
End;
end;