Adding a field that is a Formatted Memo field?

General TRichView support forum. Please post your questions here
Post Reply
alogrep
Posts: 52
Joined: Fri Oct 27, 2006 5:25 pm

Adding a field that is a Formatted Memo field?

Post by alogrep »

Hi.
I want to do this in a template (to be used at runtime to show a single page that can be previewed and/or printed):
a) I like to insert among other fields one that is a small memo.
Is it possible to do it and delimit the area inside the page where the
memo would be displayed?
example : this is the page

Code: Select all

 |-----------------------------------------------------------------------------|
 |     My  Dear:   {cust_name}                                                 |
 |     I like to remind you of the following:                                  |
 |                                                                             | 
 |   Contest:    | {memo1}   --------------------------------------------|     |
 |               |                                                       |     |
 |               |                                                       |     |
 |               |_______________________________________________________|     |
 |                                                                             |
 |    This will applay for 30 days, starting from today {today_date}           |
 |                                                                             |
 |                                                                             |
 |_____________________________________________________________________________|
The {...} are fields, and I would like to have the (rtf) content of the field {memo1} shown in that square. Is it possible? (Any demo?)

b) how can I insert a text from a regular Delphi Richedit into Richview,
so that font (color, size, style) and spacing of the text is kept?
(this is programmatically, i.e. I read the Richedit text frrm the
component and I want to copy it to a Richview component without
losing fonts and spacing). E.g the memo above.

Thanks.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

As for the given visual layout, you can implement it using tables.

Table with 2 columns and 1 row.
In the first cell: 'Contest:'
In the second cell: field which will be replaced to the formatted document.

As for implementing fields where values are arbitrary formatted documents, see Demos\Delphi\Assorted\Fields\MailMerge2\
This demo stores fields in DB in RVF format.
To use RTF instead of RVF, simple change TForm1.LoadData:
RichView2.InsertRVFFromStream(Result, 0);
to
RichView2.LoadRTFFromStream(Result, 0);

Please read comments in this demo, they are important.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

As for copying from TRichEdit, it's simple.
Use RichEdit.Lines.SaveToStream to write, and RichView.LoadRTFFromStream to read.
Formatting will be kept, assuming that
1) RichEdit.PlainText = False
2) RichView.RTFReadProperties.TextStyleMode= RichView.RTFReadProperties.ParaStyleMode=rvrsAddIfNeeded.
alogrep
Posts: 52
Joined: Fri Oct 27, 2006 5:25 pm

Post by alogrep »

Sorry Sergey, I need more help. I struggled with the Help file but I got nowhere.
Ok then suppose I have 2 or 3 tables, 2 columns each in a richviewedit.
I put the 'title' in cell[0,0] in the template (e.g. 'Contest' in my example.
Now in cell[0,1] I want to put the FORMATTED content from a Delphi Richedit. I could not find how to do this in FillFields (once I know the item is a table).
a) if table.cells[0,0].text ='Contents' . It won't work. And I realize because RV tables can contain anything, but .... how do I do what I want
to do, e.g. recognize what table it is by the text content in cells[0,0]?
b) then
table.cells[0,1]. clear (no, but what can I use to clear it?)
table.cells[0,1].Loadfromstream ... what here?
Thanks very much.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

http://www.trichview.com/support/files/copytotable.zip

Assuming that the table has this important text in the first item of Cells[0,0], you can get it as table.Cells[0,0].GetRVData.GetItemTextA(0).
Post Reply