AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Stringgrid in INI file schreiben

Ein Thema von rhodan · begonnen am 25. Apr 2014 · letzter Beitrag vom 26. Apr 2014
 
Popov
(Gast)

n/a Beiträge
 
#16

AW: Stringgrid in INI file schreiben

  Alt 26. Apr 2014, 01:51
Der erste Code könnte so aussehen:
Delphi-Quellcode:
const
  IniSelRC = 'Sel1';
  IniRowCount = 'RowCount';
  IniColCount = 'ColCount';
  IniFixedRows = 'FixRows';
  IniFixedCols = 'FixCols';
var
  x, y: Integer;
  IniFile: String;
  Ini: TIniFile;
begin
  IniFile := ChangeFileExt(ParamStr(0), '.ini');
  with StringGrid1 do
  begin
    //Speichern
    Ini := TIniFile.Create(IniFile);
    try
      //Löscht den alten Inhalt
      Ini.EraseSection(IniSelRC);

      for x := 0 to ColCount do
        Ini.WriteString(IniSelRC, IntToStr(x), Cols[x].CommaText);

      Ini.WriteInteger(IniSelRC, IniRowCount, RowCount);
      Ini.WriteInteger(IniSelRC, IniColCount, ColCount);
      Ini.WriteInteger(IniSelRC, IniFixedRows, FixedRows);
      Ini.WriteInteger(IniSelRC, IniFixedCols, FixedCols);
    finally
      Ini.Free;
    end;

    //Löschen
    for x := 0 to ColCount do
      for y := 0 to RowCount do
        Cells[x, y] := '';

    ColCount := 0;
    RowCount := 0;

    //Lesen
    Ini := TIniFile.Create(IniFile);
    try
      RowCount := Ini.ReadInteger(IniSelRC, IniRowCount, RowCount);
      ColCount := Ini.ReadInteger(IniSelRC, IniColCount, ColCount);
      FixedRows := Ini.ReadInteger(IniSelRC, IniFixedRows, FixedRows);
      FixedCols := Ini.ReadInteger(IniSelRC, IniFixedCols, FixedCols);

      for x := 0 to ColCount do
        Cols[x].CommaText := Ini.ReadString(IniSelRC, IntToStr(x), '');
    finally
      Ini.Free;
    end;
  end;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:49 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz