procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect:
TRect;
Field: TField; State: TGridDrawState);
var
P: array [0..1023] of Char; { MemoField buffer }
BS: TBlobStream;
S: string;
begin
if Field is TMemoField then
with (Sender as TDBGrid).Canvas do
begin
{ Table1Notes is the TMemoField }
BS := TBlobStream.Create(Table1Notes, bmRead);
FillChar(P, SizeOf(P), #0);
BS.Read(P, SizeOf(P));
BS.Free;
S := StrPas(P);
{ remove carriage returns & line feeds }
while Pos(#13, S) > 0 do S[Pos(#13, S)] := ' ';
while Pos(#10, S) > 0 do S[Pos(#10, S)] := ' ';
{ clear the cell }
FillRect(Rect);
{ fill cell with memo data }
TextOut(Rect.Left, Rect.Top, S);
end;
end;
|