1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| type
t_Pays = record
Code: String[3]; // Code ISO NUM des pays
Nom: String[50]; // Nom du Pays
Capitale: String[50];
// les autres infos que tu as
end;
function TForm2.LoadCombo(aFileName: String): Integer;
var
FiPays : File of t_Pays;
wPays: t_Pays;
begin
result := 0;
ComboBox1.Items.Clear;
AssignFile( FiPays, aFileName);
Reset( FiPays );
while not Eof( FiPays ) do
begin
Read( FiPays, wPays);
With wPays do
// le code sera par exemple ici : '033-FRANCE"
ComboBox1.Items.Add(Format('%3s-%s', [ wPays.Code, wPays.Nom ] ));
result := result +1;
end;
if result >0 then
ComboBox1.Items.Insert(0, 'tous ...');
end;
procedure TForm2.Button1Click(Sender: TObject);
var NbPays: Integer;
begin
NbPays := LoadCombo('PAYS.FCH');
end; |
Partager