Board index » delphi » TStrings from TMemoField problem

TStrings from TMemoField problem

Hi:

Using Delphi 3 and Paradox 7 the following fails
to provide a TStringList through which I can
iterate:

  MyStringList := TStringList.Create;
  MyStringList.Add((FieldByName('MyMemo') as
TMemoField).Value);

The reason, of course, is that I am not copying a
set of TStrings but one long string that happens
to have CRLF's embedded in it. If I copy
MyStringList to a TMemo it will be displayed
correctly because a TMemo instanition will react
correctly to those CRLF's.

How can one copy from a TMemoField to a
TStringList so that it contains TStrings without
creating a DataControl namely TDBMemo?  TDBMemo
does work well provided one has a TForm to put it
on.

       MyStringList.AddStrings(DBMemo1.Lines);

I'm not.  I'm working with a descendent of
TComponent (non-visible) in which I *could* create
a runtime instance of TDBMemo but surely there is
something more elegant.

Thanks

Nigel
/nds/

 

Re:TStrings from TMemoField problem


Hi Nigel,

Try one of these ...

MyStringList.Assign(MyTable.FieldByName('MyMemo'));

or

MyStringList.Text := MyTable.FieldByName('MyMemo').AsString;

Cheers,
Carl

Quote
"Nigel D. Scott" wrote:

---8<---

> How can one copy from a TMemoField to a
> TStringList so that it contains TStrings without
> creating a DataControl namely TDBMemo?  TDBMemo
> does work well provided one has a TForm to put it
> on.

---8<---

Re:TStrings from TMemoField problem


Try

MyStringList.Assign(Table1.FieldByName('SomeMemo'));

Bill

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Other Threads