Page 1 of 1

TDBRichViewEdit, tags and plain text question

Posted: Thu Jul 05, 2012 1:36 pm
by abranquart
Hi guys,

I need some help to implement TDBRichViewEdit on my new project :
I will use TDBRichViewEdit in “mail merge” mode, users will enter plain text, add variables/tags that was identifies by a code but users will saw a text in the editor (ex: Tag = {TAG01], Text = “<Some text>”).
At this point, everything is ok, I’m using InsertStringTag(“<Some text>”, “{TAG01}”) and it’s fine, but I need to store the text in database in text format for SQL manipulations (String replace of tags from SQL stored procedure).

I have two choices, and I have one question for each :
1. I can store text twice, one field in RVF format (for GUI editing) and another one in TXT format (for SQL manipulation), but how can I get a plain text string with tag names.

Example :
InsertStringTag(“<Some text>”, “{TAG01}”)
Text in TDBRichViewEdit : “Here is the <Some text>”
Plain text wanted : “Here is the {TAG01}”
I try using function GetAllText but it returns “Here is the <Some text>”

2. Is it possible to store plain text in database, and reload it but creating tags ?
Text stored in DB must be : “Here is the {TAG01}”
Text displayed in TDBRichViewEdit after load : “Here is the <Some text>” (tags must be created)

Thank a lot for your help.

Posted: Fri Jul 06, 2012 7:11 pm
by Sergey Tkachenko
It can be implemented either by creating your own text saving procedure, or by processing OnSaveItemToFile event.
I'll try to make an example in this weekend.

Posted: Sun Jul 08, 2012 12:57 pm
by abranquart
Hi Sergey !

I’m using labels now (TRVLabelItemInfo) for better user usage.
I have adapted the GetFormattedText that you wrote here http://www.trichview.com/forums/viewtop ... mattedtext to get the plain text result with labels/tags.

What I’m missing now, is an example of how to load plain text with labels/tags (“{TAG01}”) and replace it by real labels/tags in TDBRichViewEdit.

Thanks a lot.

Posted: Thu Jul 12, 2012 5:39 pm
by Sergey Tkachenko
The most similar demo to your request is http://www.trichview.com/support/files/ ... -text4.zip
This demo uses plain text fields (inside {}), and allows inserting different types of field values (text, picture, table).

To insert label item instead of other types of items in this demo, change TForm1.InsertField:

Code: Select all

procedure TForm1.InsertField(RVData: TCustomRVData;
  var ItemNo, Pos: Integer; const FieldName: String);
var LabelItem: TRVLabelItemInfo;
begin
  LabelItem := TRVLabelItemInfo.CreateEx(RVData, RVData.GetItemStyle(ItemNo), FieldName);
  LabelItem.Tag := FieldName;
  InsertItem(RVData, ItemNo, Pos, LabelItem);
end;