RAD Studio |  |

Copying a Complete String List
See Also
Collapse All

You can use the Assign method to copy strings from a source list to a destination list, overwriting the contents of the destination list. To append strings without overwriting the destination list, use AddStrings. For example,

Copy Code

    Memo1.Lines.Assign(ComboBox1.Items);    { overwrites original strings }

Copy Code

    Memo1->Lines->Assign(ComboBox1->Item)s;

copies the lines from a combo box into a memo (overwriting the memo), while

Copy Code

    Memo1.Lines.AddStrings(ComboBox1.Items);   { appends strings to end }

Copy Code

    Memo1->Lines->AddStrings(ComboBox1->Items);

appends the lines from the combo box to the memo.

When making local copies of a string list, use the Assign method. If you assign one string-list variable to another—

Copy Code

    StringList1 := StringList2;

Copy Code

    StringList1 = StringList2;

—the original string-list object will be lost, often with unpredictable results.

See Also

Manipulating Strings in a List

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!