Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to display memo fields in a TDBGrid Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Aug-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
75
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to display memo fields in a TDBGrid

Answer:
1   
2   procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
3     Field: TField; State: TGridDrawState);
4   var
5     P: array[0..50] of char; {array size is number of characters needed}
6     BS: tBlobStream; {from the memo field}
7     S: string;
8   begin
9     if Field is TMemoField then
10    begin
11      with (Sender as TDBGrid).Canvas do
12      begin
13        BS := tBlobStream.Create(TBlobField(Field), bmRead);
14        FillChar(P, SizeOf(P), #0); {terminate the null string}
15        BS.read(P, 50); {read 50 chars from memo into blobStream}
16        BS.Free;
17        S := StrPas(P);
18        while Pos(#13, S) > 0 do
19          S[Pos(#13, S)] := ' ';
20        while Pos(#10, S) > 0 do
21          S[Pos(#10, S)] := ' ';
22        FillRect(Rect); {clear the cell}
23        TextOut(Rect.Left, Rect.Top, S); {fill cell with memo data}
24      end;
25    end;
26  end;


For mouse right click behavior you need to intercept the right click mouse message.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC