Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Ini Datein in ein StringGrid Laden (https://www.delphipraxis.net/183865-ini-datein-ein-stringgrid-laden.html)

Rippo 10. Feb 2015 10:54


Ini Datein in ein StringGrid Laden
 
Könnte mir einer ein Beispiel geben wie ich eine Ini Datei in ein StringGrid Laden kann.
das StringGrid hat 8 Spalten mit kundennr name ansprechpartner email telefon ort straße plz

DeddyH 10. Feb 2015 11:12

AW: Ini Datein in ein StringGrid Laden
 
Quick And Dirty, gewinnt so keinen Schönheitspreis:
Delphi-Quellcode:
uses IniFiles;

const
  IniName = 'C:\Test\Test.ini';

procedure TForm38.Button1Click(Sender: TObject);
var
  Ini: TIniFile;
  Sections: TStringlist;
  i: integer;
begin
  Sections := nil;
  Ini := TIniFile.Create(IniName);
  try
    Sections := TStringList.Create;
    Ini.ReadSections(Sections);
    StringGrid1.RowCount := StringGrid1.FixedRows + Sections.Count;
    for i := 0 to Sections.Count - 1 do
      begin
        StringGrid1.Cells[StringGrid1.FixedCols, StringGrid1.FixedRows + i] := Ini.ReadString(Sections[i], 'KundenNr', '');
        StringGrid1.Cells[StringGrid1.FixedCols + 1, StringGrid1.FixedRows + i] := Ini.ReadString(Sections[i], 'Name', '');
        StringGrid1.Cells[StringGrid1.FixedCols + 2, StringGrid1.FixedRows + i] := Ini.ReadString(Sections[i], 'Ansprechpartner', '');
        (* etc. pp. *)
      end;
  finally
    Ini.Free;
    Sections.Free;
  end;
end;
Meine Ini sieht so aus:
Code:
[Kunde1]
KundenNr=1
Name=Hans Wurst
Ansprechpartner=Jim Beam
EMail=HansWurst@kunde.de
Telefon=012345/98765
Ort=Musterstadt
Straße=Sesamstraße
PLZ=11111

[Kunde2]
KundenNr=2
Name=Hans Käse
Ansprechpartner=Johnny Walker
EMail=HansKaese@nochnkunde.de
Telefon=012345/56789
Ort=Musterstadt
Straße=Einbahnstraße
PLZ=11111

Rippo 10. Feb 2015 11:23

AW: Ini Datein in ein StringGrid Laden
 
Danke :)

DP-Maintenance 24. Apr 2015 06:02

Dieses Thema wurde am "24. Apr 2015, 07:02 Uhr" von "r_kerber" aus dem Forum "Neuen Beitrag zur Code-Library hinzufügen" in das Forum "Win32/Win64 API (native code)" verschoben.


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:49 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz