🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.database
Article #150

Memo fields in TDBGrid

#150
From: Mike Zmuda
Date: Thu, 07 Sep 2006 21:56
40 lines
2326 bytes
Hello,

Does anybody know how to get a TDBGrid to display Memo fields from a database?

I've tried doing things with the DrawDataCell event, but it doesn't even
trigger. 

procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
  Field: TField; State: TGridDrawState);
Var
   P : Array[0..50] of Char;
   BS : tBlobStream;
   S  : String;
begin
     S := '';
     If Field is TMemoField then Begin
        With (Sender as TDBGrid).Canvas do Begin
             BS := tBlobStream.create(TBlobField(Field),bmRead);
             FillChar(P,SizeOf(P),#0);
             BS.Read(P,50);
             BS.Free;
             S := StrPas(P);
             While Pos(#13,S) > 0 do S[POS(#13,S)] := ' ';
             While Pos(#10,S) > 0 do S[Pos(#10,S)] := ' ';
             FillRect(Rect);
             TextOut(Rect.Left,Rect.Top,S);
        end;
     end;
end;

What am I doing wrong / is there an easier way to get the TDBGrid to display a
memo field?

(Specifically, I'm not looking for another component to display memo fields - I
have those. I'm looking to see the specific memo using the default TDBGrid
component that ships with Delphi 2006.)

Thanks -

Mike Z.
Technical Details
Message-ID: <nv41g2p6r4ae2mflh1bu5hp7u9ucrukgoi@4ax.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!69.28.186.75.MISMATCH!hwmnpeer01.lga!news.highwinds-media.com!hw-filter.lga!newsfe08.lga.POSTED!53ab2750!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 115d96,723e0e97b9cd8188,start
X-Google-Attributes: gid115d96,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!69.28.186.75.MISMATCH!hwmnpeer01.lga!news.highwinds-media.com!hw-filter.lga!newsfe08.lga.POSTED!53ab2750!not-for-mail
From: Mike Zmuda <MyaReplya@MPODR.com>
Newsgroups: borland.public.delphi.database
Subject: Memo fields in TDBGrid
Reply-To: MyMPODRReply@MPODR.COM
Message-ID: <nv41g2p6r4ae2mflh1bu5hp7u9ucrukgoi@4ax.com>
X-Newsreader: Forte Agent 4.0/32.1071
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 40
X-Complaints-To: abuse@cv.net
X-Abuse-Info: Please forward a copy of all headers for proper handling
X-Trace: adnpoonaeilogjoiijjdnojopddcmjimaanehjhnhmahkhllgeolcjbbmmfpcmllpllopkkkichgcibcomjgfomdneapobfomofpmendkdkbjfbmneapfpnjlhikjhclglbbcfickjagekga
NNTP-Posting-Date: Thu, 07 Sep 2006 14:58:36 MST
Organization: Optimum Online
Date: Thu, 07 Sep 2006 17:56:33 -0400