unit TStringsAssign;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ComboBox1: TComboBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: TStringsAssign
// Method: Classes.TStrings.Assign
// Method: Classes.TStringList.Add

// BeginCode
{
This example creates a stringlist, adds elements to it and
assigns the strings to items of a combo box.
}
procedure TForm1.Button1Click(Sender: TObject);
var
  StringList: TStringList;
begin
  StringList := TStringList.Create;
  try
    with StringList do begin
      Add('This example uses A string List.');
      Add('It is the easiest way to add strings');
      Add('to a combobox''s list of strings.');
      Add('Always remember TStrings.Create method');
      Add('is abstract; So use TStringList.Create');
      Add('method instead.');
    end;
    with ComboBox1 do begin
      Width := 210;
      Items.Assign(StringList);
      ItemIndex := 0;
    end;
  finally
    StringList.free;
  end;
end;
// EndCode
// EndExample: TStringsAssign
end.
