Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 07-23-2016, 07:22 PM
robert robert is offline
Senior Member
 
Join Date: Sep 2014
Posts: 382
Default lastchoice

I have seven edits and a checkbox on form . how can I give user option to save the changes in all the edits. so that on next if checkbox is checked changes remain in edits. May be with .ini.
  #2  
Old 07-24-2016, 06:04 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

First name the edit boxes like this (Edi1, Edit2, Edit3,....Edit9) and then use "OnCreate" and "OnClose" events of the form to save and load the values as shown below:


Code:
procedure TForm7.FormClose(Sender: TObject; var Action: TCloseAction);
var
          i   : Integer;
          oSL : TStringlist;
begin
          if CheckBox1.Checked then begin
             oSL := TStringlist.Create;

             for i:=1 to 9 do
                 oSL.Add( TEdit(self.FindComponent('Edit'+ IntToStr(i))).Text );

             oSL.SaveToFile('Values.txt');
             oSL.Free;
          end;

end;

procedure TForm7.FormCreate(Sender: TObject);
var
          i   : Integer;
          oSL : TStringlist;
begin
          if NOT FileExists('Values.txt') then
             exit;

          oSL := TStringlist.Create;
          oSL.LoadFromFile('Values.txt');

          for i:=1 to 9 do
              TEdit(self.FindComponent('Edit'+ IntToStr(i))).Text := oSL[i-1];

          oSL.Free;
end;
__________________
Regards,
Abdulaziz Jasser

Last edited by Jasser; 07-24-2016 at 01:00 PM.
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 12:57 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.