Actual linenumber in RichEdit.

How do I find out in which linenumber my cursor is placed in a TRichEdit?

I need it, because I need to insert some text with the

Richedit1.lines.insert(<here>,'MyString');

If you have better idéas for inserting text from the cursor, that will be an answer too.

Thanks.
Retep
retepAsked:
Who is Participating?
 
TheNeilConnect With a Mentor Commented:
Use the CaretPos property of the RichEdit component. In your case your call to Insert needs to be

RichEdit1.Lines.Insert(RichEdit1.CaretPos.Y, 'MyString');

The Neil =:)
0
 
kretzschmarCommented:
hi retep,

there are a api function, which can be used

or use richedit1.seltext := YournewText + #10;

meikl
0
 
simonetCommented:
Here it is:

function GetRow: Longint;
begin
  with reEdit do
    Result := Perform(EM_LINEFROMCHAR, -1, 0)+1;
end;


Yours,

Alex
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
kretzschmarCommented:
hi again,

the other solution

  Richedit1.Lines.Insert(Richedit1.Perform(EM_LINEFROMCHAR,Richedit1.Selstart,0),'Thats the New Line');

be sure that the richedit-unit is in your uses clause

meikl
0
 
retepAuthor Commented:
I have choosen to use TheNeil's answer...

Thanks to all of you :)
0
 
TheNeilCommented:
Thanks Retep - Sorry everyone else

The Neil =:)
0
All Courses

From novice to tech pro — start learning today.