Ich erlaube mir mal, Deine Procedure etwas umzuschreiben. Denn sie hat ein paar Probleme.
Vor alllem gibst Du strIniKeyAll nicht mehr frei, Du hast also ein Speicherleck.
Wenn Du den Aufruf etwas veränderst und nicht den Namen der Combobox übergibst, sondern eine Referenz auf die Combobox selber, würdest Du Dir auch FindComponent sparen.
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
| procedure TForm1.fillcombo(AComboBox : TComboBox; iniSection, iniKey : String); var I : integer; strIniKey : String;
begin
ALLinOneIni := tinifile.Create('.\test.ini'); try for I := 1 to 50 do begin strIniKey := ALLinOneIni.ReadString(iniSection, iniKey + inttostr(I),''); if strIniKey <> '' then begin AComboBox.Items.Add(strIniKey); end; end; finally ALLinOneIni.Free; end;
end; |
Der Aufruf sähe dann so aus:
Delphi-Quelltext
1:
| fillcombo(combowertb, 'material', 'matwert'); |
So ist es etwas hübscher.