was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1547)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (115)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (127)
Strings (83)
System (268)
VCL (243)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

42 Visitors Online


 
...TTreeView in Ini-Datei speichern/aus Ini lesen?
Autor: Michael Fritzsche
Homepage: http://www.frifra.de
[ Tip ausdrucken ]  

Tip Bewertung (4):  
     


procedure TreeToIni(Tree: TTreeView; INI: TIniFile; Section: string);
var
  
n: Integer;
  MS: TMemoryStream;
  tTv: TStringList;
  Msg: string;
begin
  
tTv := TStringList.Create;
  MS := TMemoryStream.Create;
  try
    
Tree.SaveToStream(MS);
    MS.Position := 0;
    tTv.LoadFromStream(MS);
    INI.EraseSection(Section);
    for n := 0 to tTv.Count - 1 do
      
INI.WriteString(Section, 'Node' + IntToStr(n), StringReplace(tTv[n], #9,
        '#', [rfReplaceAll]));
  finally
    
tTv.Free;
    MS.Free;
  end;
end;

procedure TreeFromIni(Tree: TTreeView; INI: TIniFile; Section: string;
  Expand: Boolean);
var
  
n: Integer;
  MS: TMemoryStream;
  tTv: TStringList;
  Msg: string;
begin
  
tTv := TStringList.Create;
  MS  := TMemoryStream.Create;
  try
    
INI.ReadSection(Section, tTv);
    for n := 0 to tTv.Count - 1 do
      
tTv[n] := StringReplace(INI.ReadString(Section, tTv[n], ''), '#', #9,
        [rfReplaceAll]);
    tTv.SaveToStream(MS);
    MS.Position := 0;
    Tree.LoadFromStream(MS);
    if (Expand = True) and (Tree.Items.Count > 0) then
      
Tree.Items[0].Expand(True);
  finally
    
tTv.Free;
    MS.Free;
  end;
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners