Results 1 to 3 of 3

Thread: nobie question - how to save

  1. #1
    scratch
    Guest

    nobie question - how to save

    i have 2 groupbox's in form1, and in both i have like 5 checkbox's.i also have a button called btnSave and another called btnLoad. my question is, how can i make it so when i click btnSave, the staus of all the checkbox's (whether they are checked or not) is saved to a file. and when i press btnLoad, they are loaded.
    hope i made myself clear. :?
    i really need an answer for this urgently.
    thanks in advance.

  2. #2

    nobie question - how to save

    Wheather checkboxs are checked is represented by their boolean property Checked, so all you need is save and load them.

  3. #3

    nobie question - how to save

    Hi,

    you could use an ini file to store the propertise:

    [pascal]
    uses
    IniFiles;

    procedure LoadFromFile;
    var
    Ini: TIniFile;
    begin
    Ini := TIniFile.Create('MyInifile.ini');

    // Read a boolean variable from ini, section 'Group1' default values is true.
    CheckBox1.Checked := Ini.ReadBoolean('Group1', 'Checkbox1', True);
    CheckBox2.Checked := Ini.ReadBoolean('Group1', 'Checkbox2', True);
    CheckBox3.Checked := Ini.ReadBoolean('Group1', 'Checkbox3', True);
    CheckBox4.Checked := Ini.ReadBoolean('Group1', 'Checkbox4', True);
    CheckBox5.Checked := Ini.ReadBoolean('Group1', 'Checkbox5', True);

    // Read a boolean variable from ini, section 'Group2' default values is true.
    CheckBox6.Checked := Ini.ReadBoolean('Group2', 'Checkbox6', True);
    CheckBox7.Checked := Ini.ReadBoolean('Group2', 'Checkbox7', True);
    CheckBox8.Checked := Ini.ReadBoolean('Group2', 'Checkbox8', True);
    CheckBox9.Checked := Ini.ReadBoolean('Group2', 'Checkbox9', True);
    CheckBox10.Checked := Ini.ReadBoolean('Group2', 'Checkbox10', True);

    Ini.Free;
    end;

    procedure SaveToFile;
    var
    Ini: TIniFile;
    begin
    Ini := TIniFile.Create('MyInifile.ini');

    // Read a boolean variable from ini, section 'Group1' default values is true.
    Ini.WriteBoolean('Group1', 'Checkbox1', CheckBox1.Checked);
    Ini.WriteBoolean('Group1', 'Checkbox2', CheckBox2.Checked);
    Ini.WriteBoolean('Group1', 'Checkbox3', CheckBox3.Checked);
    Ini.WriteBoolean('Group1', 'Checkbox4', CheckBox4.Checked);
    Ini.WriteBoolean('Group1', 'Checkbox5', CheckBox5.Checked);

    // Read a boolean variable from ini, section 'Group2' default values is true.
    Ini.WriteBoolean('Group2', 'Checkbox6', CheckBox6.Checked);
    Ini.WriteBoolean('Group2', 'Checkbox7', CheckBox7.Checked);
    Ini.WriteBoolean('Group2', 'Checkbox8', CheckBox8.Checked);
    Ini.WriteBoolean('Group2', 'Checkbox9', CheckBox9.Checked);
    Ini.WriteBoolean('Group2', 'Checkbox10', CheckBox10.Checked);

    Ini.Free;
    end;
    [/pascal]
    Hope this helps..
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •