TStringsAssign (C++)
Description
This example creates a string list, adds elements to it, and assigns the strings to the items of a combo box.
Code
#include <memory> //For STL auto_ptr class
void __fastcall TForm1::Button1Click(TObject *Sender)
{
std::auto_ptr<TStrings> StringList(new TStringList());
StringList->Add("This example uses A string List. ");
StringList->Add("It is the easiest way to add strings");
StringList->Add("to a combo box's list of strings. ");
StringList->Add("Always remember TStrings is abstract,");
StringList->Add("so create a TStringList instead.");
ComboBox1->Width = 210;
ComboBox1->Items->Assign(StringList.get());
ComboBox1->ItemIndex = 0;
}
Uses
- System.Classes.TStrings.Assign ( fr | de | ja )
- System.Classes.TStringList.Add ( fr | de | ja )