Link to home
Start Free TrialLog in
Avatar of esk
esk

asked on

Inthe---> save all treeview in INI file

Hello Inthe, question for you

save all treeview in INI file and load it back

Esk
Avatar of edey
edey

does it have to be an ini file? or could something like this help:


SaveToFile saves a the tree view to the file specified in FileName.

procedure SaveToFile(const FileName: string);

Description

Use the SaveToFile method to store tree view data to a text file. The nodes can later be reloaded from the file into a new tree view object using the LoadFromFile method.


GL
mike
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 esk

ASKER

yes, thanks
listening...
I have a much simpler way, granted it would need a little fine tuning for your specific case. But here goes:
unit helpered1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls, IniFiles;

type
  TForm1 = class(TForm)
    TreeView1: TTreeView;
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
        I: integer;
        Settings: TIniFile;
        MyIniFile: string;
begin
MyIniFile := ExtractFilePath(Application.Exename) + 'output.ini';
Settings := TIniFile.Create(Myinifile);
  for I := 0 to (TreeView1.Items.Count -1 ) do
Settings.WriteString(treeview1.topitem.Text, IntToStr(i), TreeView1.Items.Item[I].Text);
end;
end.
(the editbox isnt needed, I just added it for debugging and playing around with the code :) )
hi
but how to load a empty tree from ini file?
i had a few goes with no luck ;-(
Avatar of esk

ASKER

yeh, now is your turn again "gideon00"

Esk
Avatar of esk

ASKER

do you have any code "gideon00's" ?
but you rejected my answer *sniff*
Avatar of esk

ASKER

sorry, i give you the points if you can come with code that's load it back

Esk