2008. december 6., szombat

How to save items of a TComboBox to an ini file


Problem/Question/Abstract:

How to save items of a TComboBox to an ini file

Answer:

This is one possibility. It will put the items in a seperate section:

procedure TForm1.WriteComboToIni;
var
  IniFile: TIniFile;
  Cnt: integer;
begin
  IniFile := TIniFile.Create('c:\test.ini');
  try
    with ComboBox1 do
      if Items.Count > 0 then
        for Cnt := 0 to Items.Count - 1 do
          IniFile.WriteString('Section', 'Items' + IntToSTr(Cnt), Items[Cnt]);
  finally
    IniFile.Free;
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése