Board index » delphi » TMemo - After lines.clear getting cursor on line 1.

TMemo - After lines.clear getting cursor on line 1.

I have a TMemo are on my screen that after the enter key is pressed the
entire contents are copied to another memo area.  Then I perform a
Memo1.Lines.Clear all of the lines are cleared but the cursor is on the
second line.  How do I get it place the cursor on the 1st line?

Should I be using Memo.Text.(something) to empty the memo component?

Rick Cromer
r-cro...@ti.com
http://www.flash.net/~rcromer/

 

Re:TMemo - After lines.clear getting cursor on line 1.


Quote
"Rick Cromer" <r-cro...@ti.com> wrote:
>I have a TMemo are on my screen that after the enter key is pressed the
>entire contents are copied to another memo area.  Then I perform a
>Memo1.Lines.Clear all of the lines are cleared but the cursor is on the
>second line.  How do I get it place the cursor on the 1st line?

Try:

  Memo1.SelStart := 0;

Share and Enjoy!

+--------------------from usenet----------------------+
|  Anders Bo Melander    | Phone: (+45) 31 87 91 26   |
|  Finsensvej 79, 2. tv. | mailto:a...@biocat.ruc.dk  |
|  DK-2000 Frederiksberg | work: a...@lrsoftware.dk    |
|  Denmark               | flameto:bi...@microsoft.com|
+------------------------+----------------------------+
| http://ftp.frontier.dk/public/Delphi2/tbedit01.html |
+-----------------------------------------------------+

Re:TMemo - After lines.clear getting cursor on line 1.


Rick Cromer <r-cro...@ti.com> wrote in article
<01bc2420$f746d8a0$472a1...@cromer.itg.ti.com>...

Quote
> I have a TMemo are on my screen that after the enter key is pressed the
> entire contents are copied to another memo area.  Then I perform a
> Memo1.Lines.Clear all of the lines are cleared but the cursor is on the
> second line.  How do I get it place the cursor on the 1st line?

> Should I be using Memo.Text.(something) to empty the memo component?

> Rick Cromer
> r-cro...@ti.com
> http://www.flash.net/~rcromer/

I just tried the code below and it put the caret on line 1 of memo1.
If this don't help, post an example of what you are doing or email me.

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  If (Key = VK_RETURN) then
  begin
    with Memo2.Lines do
    Memo2.Lines := memo1.Lines;
    with Memo1.Lines do
    Memo1.Lines.clear;
  end;
end;

Other Threads