I can't see content of the memo field in DBGrid

----- Original Message -----
From: "Goran" <gesi...@verat.net>
Subject: I can't see content of the memo field in DBGrid
> I have DBGrid with custom table on my form, but I can't see
> content of the memo field. I see only text (MEMO) in each row.

I have read this somewhere and it worked for me. Write a OnDrawColumnCell
routine like this:

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
  If Column.FieldName = 'MyMemoField' then          // replace with your
field name
    DrawMemoCell( Sender, Rect, Query1, 'MyMemoField');

procedure TForm1.DrawMemoCell( Sender: TObject; const Rect: TRect;
                       xTable: TQuery; cField: string );
 cChars  : array [0..501] of char;   {array size is number of characters
 xBlob   : TBlobStream;              {from the memo field}
 cStr    : string;
 with (Sender as TDBGrid).Canvas do begin
   {Table1Notes is the TMemoField}
   xBlob := TBlobStream.Create( TBlobField( xTable.FieldByName(cField)),
bmRead );
   FillChar( cChars, SizeOf( cChars ), #0 );   {terminate the null string}
   xBlob.Read( cChars, 500 );    {read chars from memo into blobStream}
   cStr := StrPas( cChars );
   while Pos( #13, cStr ) > 0 do              {remove carriage returns and}
     cStr[ Pos( #13, cStr )] := ' ';          {line feeds}
   While Pos( #10, cStr ) > 0 do
     cStr[ Pos( #10, cStr )] := ' ';
   FillRect( Rect );                          {clear the cell}
   TextOut( Rect.Left + 3, Rect.Top + 2, cStr ){fill cell with memo data}
end; {DrawMemoCell }

Hope it will work for you.
Marcio Ehrlich