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 copy RTF text to a TMemo via a TStringStream 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
30-Aug-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
41
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to copy RTF text to a TMemo via a TStringStream

Answer:

Here is a method to copy the formatted text to a memo via a stringstream. The same 
approach should work to store it in a database field that takes a string.
1   
2   procedure TForm1.Button1Click(Sender: TObject);
3   var
4     ss: TStringStream;
5   begin
6     ss := TStringStream.Create(EmptyStr);
7     try
8       richedit1.plaintext := false;
9       richedit1.lines.savetostream(ss);
10      memo1.text := ss.DataString;
11    finally
12      ss.free;
13    end;
14  end;
15  
16  procedure TForm1.Button2Click(Sender: TObject);
17  var
18    ss: TStringStream;
19  begin
20    ss := TStringStream.Create(memo1.text);
21    try
22      richedit1.plaintext := false;
23      richedit1.lines.LoadFromstream(ss);
24    finally
25      ss.free;
26    end;
27  end;


To simply copy formatted text from a TRichEdit to a string, you could also use:
28  
29  function GetRawRTFText(aRichedit: TRichedit): string;
30  var
31    SS: TStringstream;
32  begin
33    SS := TStringstream.Create(EmptyStr);
34    try
35      aRichedit.plaintext := False;
36      arichedit.Lines.SaveToStream(SS);
37      Result := SS.DataString;
38    finally
39      SS.Free
40    end;
41  end;


			
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