I am using a TMemo box intead of a TEdit box simply because of the multi-line ability.

I was guessing and I used the .Text property to assign a value at run-time. But then I realised that there was no Text property at design time. Rather I found the Lines property.

I checked this page: http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tmemo.html for more info.

I found out that there is no Text property but only a Lines property in that documentation.

Is my use of .Text correct or is it a problem using this?

Here's my code:

  if dlgSave.Execute Then
     begin
       txtSaveName.Text := dlgSave.FileName;
     end;

txtSaveName : TMemo

dlgSave : TSaveDialog

Thanks for any inputs.

有帮助吗?

解决方案

Lines is a TStrings, a class that is basically a wrapper for an array of strings.

Text is a simple property that when read concatenates the strings together (with lineseparators between them), and when assigned too parses the single string into multiple strings.

I wouldn't worry too much about it, just think twice before using it for huge strings (think hundreds of MBs and bigger), since all the copying done by this highlevel functionality will eat quite some memory.

Another (minor) reason not to use it is if you want reading and writing to be binary the same. Assume you have a text with mixed line endings and you assign it to text and read it back, then the mixed lineendings will be uniform now.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top