Page 1 of 1

How to get all the text of a line from richviewEdit?

Posted: Mon Feb 20, 2012 3:22 pm
by alexandreq
Hello,

There is a way to get all text from a line in RichEdit, but how to do this in richViewEdit?

In RichEdit I only do this:

Var
S : String;
Begin
S := RichEdit.Lines[0];
ShowModal(S)
End;

And in RichViewEdit?

Thanks

Posted: Tue Feb 21, 2012 3:03 pm
by j&b
One solution (memo has focus - TDBRichViewEdit)

procedure TForm1.btnTest1Click(Sender: TObject);
begin
memo.setfocus
memo.SelectCurrentLine; //in this case: 1st line
s:=memo.getseltext;
memo.deselect;
ShowMessage(s);
end;

Posted: Tue Feb 21, 2012 7:40 pm
by Sergey Tkachenko
You can use the functions from RVGetTextW.pas (or RVGetText.pas, if you need ANSI text).

Code: Select all

function GetCurrentLineText(rve: TCustomRichViewEdit): TRVUnicodeString;
function GetCurrentParaText(rve: TCustomRichViewEdit): TRVUnicodeString;

Posted: Tue Feb 21, 2012 10:52 pm
by alexandreq
hi sergey,

thanks for reply me.

How would you do this?

Specify a determined line and get a text from it?

like a function

rveGetLine(line) return string

should I move the caret to it and get the current line? But if I don't want move the caret? is there any solution?

Posted: Wed Feb 22, 2012 6:32 pm
by Sergey Tkachenko
Do you need a line on the screen (that depends on wordwrapping/window size) or a paragraph (text between Returns)?

Posted: Wed Feb 22, 2012 6:52 pm
by alexandreq
I need to get a determined line from screen.