Link to home
Start Free TrialLog in
Avatar of karen021897
karen021897

asked on

write all in listbox into "ini" file and vice versa

when i close the app i will be able to write all text that are in listbox into "ini" file, and when i open the app i will read from "ini" file into listbox. Is this possible in Delphi?
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of inthe
inthe

oops ,dont need
ii : integer; line it just was me testing stuff
You don't have to use an inifile for this, but you sure can if you want to.
Perhaps a simpler way of doing this is to use the SaveToFile and LoadFromFile functions.  Here is a little example that you can try on a form.  Just drop a list box on the form and copy the following code.

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ListBox1.Items.SaveToFile('C:\test.txt');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  if FileExists('C:\test.txt') then  //since the file doesn't exist the first time you run it
    ListBox1.Items.LoadFromFile('C:\test.txt');
end;
Avatar of karen021897

ASKER

Thanks Again!!!