使用TIniFile.ReadAllSections将所有部分的名称检索到TStrings后代中,这可能是ComboBox.Items.
ComboBox1.Items.Clear;
Ini.ReadAllSections(ComboBox1.Items);
用法:
[1038]
AValue = a1
BValue = b1
CValue = c1
DValue = d1
[1031]
AValue = a2
BValue = b2
CValue = c2
DValue = d2
I use this procedure for filling the grid:
procedure TForm1.ReadIntoGrid(const aIniFileName, aSection: string;
const aGrid: TStringGrid);
var
Ini: TIniFile;
SL: TStringList;
i: Integer;
begin
SL := TStringList.Create;
try
Ini := TIniFile.Create(aIniFileName);
try
aGrid.ColCount := 2;
Ini.ReadSectionValues(aSection, SL);
aGrid.RowCount := SL.Count;
for i := 0 to SL.Count - 1 do
begin
aGrid.Cells[0,i] := SL.Names[i];
aGrid.Cells[1,i] := SL.ValueFromIndex[i];
end;
finally
Ini.Free;
end;
finally
SL.Free;
end;
end;
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.044843912124634 seconds