Board index » delphi » Second try: TStringList and Memo

Second try: TStringList and Memo

Got some confusion about last post.

What I want to do is to assign lines from a TStringList to a Memo.

Var
  Texts : array[0..10] of TStringList;
begin
  [snip!] { create all texts }
  Memo1.Lines.Assign(Texts[0]);
end;

This does _not_ work!
If I try to do the same thing with a ListBox, it works.
I have also tried:

Memo1.Lines := Texts[0];

And

For I := 0 to Texts[0].Count do
  Memo1.Lines.Add(Texts[0][I]);

Without any success.
If I have just one line, it works!

Can anyone help mw with this?

--
Sten Karsten Vartdal
stenvart-remo...@online.no
http://home.sol.no/~stenvart/

 

Re:Second try: TStringList and Memo


Well, it works here.
Assuming the creation of texts is done correctly it should work.
I got curious, so I had to try.
Seemes like you have to post some more of your code in order to get
help.

Geir

On Wed, 29 Apr 1998 19:10:07 +0200, "Sten Karsten Vartdal"

Quote
<stenv...@online.no> wrote:
>Got some confusion about last post.

>What I want to do is to assign lines from a TStringList to a Memo.

>Var
>  Texts : array[0..10] of TStringList;
>begin
>  [snip!] { create all texts }
>  Memo1.Lines.Assign(Texts[0]);
>end;

>This does _not_ work!
>If I try to do the same thing with a ListBox, it works.
>I have also tried:

>Memo1.Lines :=3D Texts[0];

>And=20

>For I :=3D 0 to Texts[0].Count do
>  Memo1.Lines.Add(Texts[0][I]);

>Without any success.
>If I have just one line, it works!

>Can anyone help mw with this?

>--=20
>Sten Karsten Vartdal
>stenvart-remo...@online.no
>http://home.sol.no/~stenvart/

------------------
Geir Tutturen
email: geir.tuttu...@itf.nlh.no

Re:Second try: TStringList and Memo


I've used the following succesfully:
Memo1.Lines.Text := Memo1.Lines.Text + 'whatever you need'

And remember to add #13 and #10 where you want line breaks

Cheers!  Jacques

In article <6i80se$1i...@o.online.no>, "Sten Karsten Vartdal"

Quote
<stenv...@online.no> wrote:
>Got some confusion about last post.
>What I want to do is to assign lines from a TStringList to a Memo.
>Var
>  Texts : array[0..10] of TStringList;
>begin
>  [snip!] { create all texts }
>  Memo1.Lines.Assign(Texts[0]);
>end;

>This does _not_ work!
>I have also tried:
>Memo1.Lines :=3D Texts[0];
>And=20
>For I :=3D 0 to Texts[0].Count do
>  Memo1.Lines.Add(Texts[0][I]);
>Without any success.
>If I have just one line, it works!
>Can anyone help mw with this?
>--=20
>Sten Karsten Vartdal
>stenvart-remo...@online.no

:-:-:
:-:-: Jacques Simard
:-:-: Simard.Jacq...@ic.gc.ca
:-:-: PGP 2.63i Fingerprint: 48 27 22 52 40 7E 33 87  53 F5 3D 23 1C 29 52 C3
:-:-:

Re:Second try: TStringList and Memo


Sten Karsten Vartdal heeft geschreven in bericht
<6i80se$1i...@o.online.no>...
Got some confusion about last post.

What I want to do is to assign lines from a TStringList to a Memo.

Var
  Texts : array[0..10] of TStringList;
begin
  [snip!] { create all texts }
  Memo1.Lines.Assign(Texts[0]);
end;

This does _not_ work!

Try:
  for i := 0 to 10 do
      Memo1.Lines.AddStrings(Texts[i]);

Regards,
Dirk Claessens
______________________________________________
dirk.claessens@village.#NOSPAM#uunet.be
dirk.claessens.dc@belgium.#NOSPAM#agfa.com
remove #NOSPAM#  from mailheader
______________________________________________

Re:Second try: TStringList and Memo


Sten Karsten Vartdal <stenv...@online.no> schrieb im Beitrag
<6i80se$1i...@o.online.no>...
Got some confusion about last post.

What I want to do is to assign lines from a TStringList to a Memo.

Memo : TMemo;
Text : TStringList;

Memo.Lines.Assign(Text.Strings);

Re:Second try: TStringList and Memo


On 2 May 1998 18:45:44 GMT, "Marco Machicao" <mmachi...@pc-notruf.de>
wrote:

Quote

>Sten Karsten Vartdal <stenv...@online.no> schrieb im Beitrag
><6i80se$1i...@o.online.no>...
>Got some confusion about last post.

>What I want to do is to assign lines from a TStringList to a Memo.

>Memo : TMemo;
>Text : TStringList;

>Memo.Lines.Assign(Text.Strings);

Here is a working example for you; illustrated within the OnClick
event handler of a TButton :

procedure TForm1.Button1Click(Sender: TObject);
var
  StringList1: TStringList;
begin

  try
    StringList1 := TStringList.Create;
    StringList1.Add('A');
    StringList1.Add('B');
    StringList1.Add('C');
    Memo1.Lines.Assign(StringList1);
  finally
    StringList1.Free;
  end;

end;

Re:Second try: TStringList and Memo


I now realized what went wrong.
Because I used the OnChange event in the memo to save the contents. And then when I tried to assign the TStringList to the memo, it would change and alter the contents in the TStringList!
Sorry about the trouble!
But thanks!

--
Sten Karsten Vartdal
stenvart-remo...@online.no
http://home.sol.no/~stenvart/

Re:Second try: TStringList and Memo


  As I remember Memo.Lines is of TStringList type, so why you are using
Array of StringList, use just StringList, so what you want will look
like following:

    Memo1.Lines := Tests.Stings

tStringList.Strings is the one who holds the actual strings, as I
rememeber. Try using this!

Konstantin Ulianov

VR Studio

Re:Second try: TStringList and Memo


Quote
Konstantin Ulianov wrote:

>   As I remember Memo.Lines is of TStringList type [...]

Not. Memo.Lines is is property of TStrings type. TStrings is abstract
class. And TStringList is TStrings' non-abstract descendant.

---------
Andrzej Sibik     mailto:asi...@silesia.pik-net.pl

Other Threads