DB Grid Question...

I'm using a DB Grid to display the contents of a database. The Memo field though doesn't show up, it just says: (MEMO).  How can I have it display the contents of the Memo field when the box is double-clicked?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

try this DrawMemoCell proc  adapted straight from Borlands Delphi FAQ :
procedure TResultsForm.DBGrid1DrawDataCell(Sender: TObject;
  const Rect: TRect; Field: TField; State: TGridDrawState);
  if Field is TMemoField then
    DrawMemoCell( Sender, Rect, ResultsTable, 'TITLE');
procedure DrawMemoCell( Sender: TObject; const Rect: TRect;
                        xTable: TTable; cField: string );
  cChars  : array [0..501] of char;  {array size is number of characters needed}
  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}     xBlob.Free;
    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}

Regards Barry
you could put up a memo component under the grid which'd show the memo data as the records scrolled by on the grid, or if you even want to have a small modal window show up by clicking on the field in the grid

all's you'd have to do for the latter is stick a click event on the grid which'd open the memo display dialog

ex.  make a small form, stick a dbmemo on it.

in the gridclick event... create the form, set the datasource property of the memo control to the calling form's datasource, show it modally, then dispose of it when you're done

hope this helps... ;)
dokkenAuthor Commented:

I'm using that DBISAM database component and the TTable turned out to not be compatible with it.


Your method works great. Post something as an answer so I can give you the points.

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

My answer.... ;)


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
U can place a DB MEMO in the form .
Set it's  datafield and datasource.
On the Gird's MouseClick get the coordinates of the memo cell using function CellRect.
Set the DBMEMO's coordinates to the grids cells  using function Setbounds .

dokkenAuthor Commented:

Thanks again for the answer.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.