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,
Memo1.Lines.Assign(ComboBox1.Items); { overwrites original strings }
Memo1->Lines->Assign(ComboBox1->Item)s;
copies the lines from a combo box into a memo (overwriting the memo), while
Memo1.Lines.AddStrings(ComboBox1.Items); { appends strings to end }
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—
StringList1 := StringList2;
StringList1 = StringList2;
—the original string-list object will be lost, often with unpredictable results.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|