Board index » delphi » TMemo: Which lines am I on?

TMemo: Which lines am I on?

TMemo: Which line am I on?

Using a popup menu, I want to add text to a line in a TMemo. (I'm
actually adding html code.) I could do this by typing:

Memo1.Lines[0] := Memo1.Lines[0]+'<BR>';

The problem is that the user may not actually be on line #1.

For fun I have also tried:

procedure TForm1.LineBreakbr1Click(Sender: TObject);
  i : integer;
for i := 0 to Memo1.Lines.Count - 1 do
Memo1.Lines[i] := Memo1.Lines[i]+'<BR>';

But of course this adds '<BR>' to the end of every line. Is there a way
of reading JUST the line the user is presently on and setting [n] so the
text is just printed JUST on that line?

Memo1.Lines[n] := Memo1.Lines[n]+'<BR>';

Much appreciated!


Re:TMemo: Which lines am I on?

In article <>, Nathalie

<> writes:
>TMemo: Which line am I on?

LineNo{zero based} := Memo1.Perform(EM_LINEFROMCHAR, -1, 0);

Returns the line the caret (or the start of the selection)  is on.

Alan Lloyd

Other Threads