Mail Merging a tStringGrid into a tRichView

General TRichView support forum. Please post your questions here
Post Reply
GerryD
Posts: 10
Joined: Wed Oct 06, 2010 1:07 am
Location: Dallas

Mail Merging a tStringGrid into a tRichView

Post by GerryD »

I've reviewed the mail merge demos and I have some questions and am in need of some advice. In my application the mail merge template is provided by the customer as an RTF file with the appropriate field names tagged between []s. One of the fields I need to merge is a tStringGrid from one of my applications forms. A complication is I've taken over the CellDraw event for the tStrigGrid so the background color of the cell is a function of the text. So it's not a straight text merging problem.

What's the best way to get this data into a tRichView so I can print it? If I wanted to put two tStringGrids side by side in the document would it be best to use TextBoxs around them or maybe stick them into a two cell table?
Would it be easier just to grab the tStringGird canvas and merge in the data as graphics images?

Any recommendations would be appreciated.
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

May be you can convert this string grid to a table (TRVTableItemInfo) with the proper colors of cells?
GerryD
Posts: 10
Joined: Wed Oct 06, 2010 1:07 am
Location: Dallas

Post by GerryD »

So i went down this path. I can build a TRVTableItemInfo with the data from my StringGrid but I can't figure out how to insert it into my tRichView. Here's the snippet of code from the mail merge demo


FieldName := Copy(s, j+1, FieldEnd-j-1);
FieldValue := GetFieldValueFromDatabase(FieldName);
Delete(s, j, FieldEnd-j+1);
Insert(FieldValue, s, j);

Which I've turned into this for a simple test

FieldName := Copy(s, j+1, FieldEnd-j-1);
Delete(s, j, FieldEnd-j+1);
if FieldName = 'MyStringSridField' then
begin
// Build TRVTableItemInfo
atable := TRVTableItemInfo.CreateEx(3,3, RVData);
// Fill in the Cells
// Some uninteresting code

// How do I insert it???

end
else
begin
FieldValue := GetFieldValueFromDatabase(FieldName);
Insert(FieldValue, s, j);
end;


My table data doesn't show up in my Richedit. I can do a richedit.additem('',atable) and the data shows up but at the end of the document not where the mailmerge fieldname was.
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

http://www.trichview.com/support/files/ ... -text4.zip demo supports the following field values: text, picture, table.
GerryD
Posts: 10
Joined: Wed Oct 06, 2010 1:07 am
Location: Dallas

Post by GerryD »

Thanks. That's works great but it gets me back to one of my original questions.

" If I wanted to put two tStringGrids side by side in the document would it be best to use TextBoxs around them or maybe stick them into a two cell table?

So I tried the two cell table and it worked but I can't get Trichview to read my RTF template with Text Boxes. The texxtbox and the text inside isn't displayed. So I just tried a simple LoadRTF() with the same result.

Doesn't the latest version of tRichview support text boxes?
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, TRichView does not support floating objects in RTF, including text boxes.
Use a table with two cells.
GerryD
Posts: 10
Joined: Wed Oct 06, 2010 1:07 am
Location: Dallas

Colum Widths in mail-merged tStringGrid

Post by GerryD »

I'm finally getting back to this after a brief layoff.

So as I mentioned previously I'm getting the stringgrids place correctly on the page inside some table cells that describe the layout of the stringgrids relative to each other.

My new problem is that TRichView is automatically changing the widths of the columns to fit into the cells. Is there a way to change this behavior to keep the relative size of all the columns constant?
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I am not sure that I understand how you want to change/lock column sizes.
Can you explain with more details?
Post Reply