Hello everyone!
I've been working on a project that allows the users to create their own documents templates. Each template may have fields(tags) and its contents may be stored in a database.
There are some tags that is necessary have more than one line. So here is my problem, when I try to get the text of such tag, I get just one line of the tag.
My question is. Is it possible to get the text of the entire tag?
PS: I'm using the InsertStringTag function.
thanks in advance
tag used as memo
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Tags can contain multiline strings.
This code shows a messagebox containing multiline text:
Items having multiline tags can be saved and loaded in RVF format.
This code shows a messagebox containing multiline text:
Code: Select all
RichViewEdit1.InsertStringTag('aaa', '1'#13'2'#13'3');
Application.MessageBox(PChar(RichViewEdit1.GetCurrentTag), 'Tag', 0);
hi, thanks for your answer, but i'm still in doubt. I couldn't explain correctly because my english is too bad.
You showed me how to put a tag with multiline text RichViewEdit1.InsertStringTag('aaa', '1'#13'2'#13'3');. I want to know if is possible put a text with multilines, just the opposite that showed.
RichViewEdit1.InsertStringTag('1'#13'2'#13'3', 'aaa');
I'm using InsertStringTag to put a tag, it serves as a index to get the text of the tag. For example: RichViewEdit1.InsertStringTag('text that I want to get in multi lines', 'tag_memo');
[/img]
You showed me how to put a tag with multiline text RichViewEdit1.InsertStringTag('aaa', '1'#13'2'#13'3');. I want to know if is possible put a text with multilines, just the opposite that showed.
RichViewEdit1.InsertStringTag('1'#13'2'#13'3', 'aaa');
I'm using InsertStringTag to put a tag, it serves as a index to get the text of the tag. For example: RichViewEdit1.InsertStringTag('text that I want to get in multi lines', 'tag_memo');
[/img]
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
In InsertStringTag, the string must not contain line break characters.
There is a method InsertText that can insert multiline text, but it does not support tags.
If you need to insert a multiline text with tag, use a function like this:
There is a method InsertText that can insert multiline text, but it does not support tags.
If you need to insert a multiline text with tag, use a function like this:
Code: Select all
var sl: TStringList;
rve: TCustomRichViewEdit;
i: Integer;
begin
sl := TStringList.Create;
sl.Text := '1'#13'2'#13'3';
rve := RichViewEdit1.TopLevelEditor;
rve.BeginUndoGroup(rvutInsert);
rve.SetUndoGroupMode(True);
rve.BeginUpdate;
for i := 0 to sl.Count-1 do begin
rve.InsertStringTag(sl[i], 'tag example');
if i<sl.Count-1 then
rve.InsertText(#13);
end;
rve.EndUpdate;
rve.SetUndoGroupMode(False);
sl.Free;
end;
-
- Posts: 3
- Joined: Wed Jul 22, 2015 2:55 pm
hello, everyone!
Thank you Sergey for the help.
I've made this function, if anyone is interested.
It is attending my needs when I want to get a Tag text with multilines.
///alteração 06/08/2015
///função que pega todas as linhas de um field de multilinhas
function TFEditor.GetMultilineFieldText(rv : TCustomRichView; const AField:string; ItemNo:Integer): string;
var
sValue: string;
i:integer;
vItem : TCustomRVItemInfo;
bTagDiferent, bLastItem : boolean;
begin
GetFieldValue(rv, AField, ItemNo);
sValue := '';
i := itemNo;
repeat
vItem := rv.GetItem(i);
bTagDiferent := (vItem.Tag <> AField);
bLastItem := rv.ItemCount -1 = i;
if not bTagDiferent then begin
sValue := sValue + ' '+#13 + vItem.ItemText;
end;
i := i+1;
until (bTagDiferent or bLastItem);
result := sValue;
end;
Thank you Sergey for the help.
I've made this function, if anyone is interested.
It is attending my needs when I want to get a Tag text with multilines.
///alteração 06/08/2015
///função que pega todas as linhas de um field de multilinhas
function TFEditor.GetMultilineFieldText(rv : TCustomRichView; const AField:string; ItemNo:Integer): string;
var
sValue: string;
i:integer;
vItem : TCustomRVItemInfo;
bTagDiferent, bLastItem : boolean;
begin
GetFieldValue(rv, AField, ItemNo);
sValue := '';
i := itemNo;
repeat
vItem := rv.GetItem(i);
bTagDiferent := (vItem.Tag <> AField);
bLastItem := rv.ItemCount -1 = i;
if not bTagDiferent then begin
sValue := sValue + ' '+#13 + vItem.ItemText;
end;
i := i+1;
until (bTagDiferent or bLastItem);
result := sValue;
end;