Recent

Author Topic: Writing at cursorposition in TMemo  (Read 6116 times)

T-bear

  • Full Member
  • ***
  • Posts: 160
Writing at cursorposition in TMemo
« on: March 25, 2011, 09:22:01 pm »
Hi  :)

How can i write a string variable into a TMemo, at the position of the cursor?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Writing at cursorposition in TMemo
« Reply #1 on: March 25, 2011, 09:30:24 pm »
Code: [Select]
Memo1.SelText := 'abc';   

T-bear

  • Full Member
  • ***
  • Posts: 160
Re: Writing at cursorposition in TMemo
« Reply #2 on: March 25, 2011, 09:52:32 pm »
And if i want to insert the text from a Textfile?

Thanks!  :)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Writing at cursorposition in TMemo
« Reply #3 on: March 25, 2011, 10:54:29 pm »
You can load the file to a TStringList and set its Text property to the TMemo's SelText property.

T-bear

  • Full Member
  • ***
  • Posts: 160
Re: Writing at cursorposition in TMemo
« Reply #4 on: March 25, 2011, 11:30:00 pm »
??? How? ???  %)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Writing at cursorposition in TMemo
« Reply #5 on: March 25, 2011, 11:49:57 pm »
Code: [Select]
var
  sl :TStringList;
begin
  sl := TStringList.Create;
  try
    sl.LoadFromFile(UTF8toAnsi('Filename.txt'));
    Memo1.SelText := sl.Text;
  finally
    sl.Free;
  end;
end; 

 

TinyPortal © 2005-2018