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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.t xt');
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.LoadFromFil e('C:\test .txt');
end;
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(
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.LoadFromFil
end;
ASKER
Thanks Again!!!
ii : integer; line it just was me testing stuff