3 TlistBox

Résolu
grod0026 Messages postés 141 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 22 septembre 2023 - 19 déc. 2009 à 21:43
grod0026 Messages postés 141 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 22 septembre 2023 - 2 janv. 2010 à 22:34
bonsoir,
voila je développe un petit programme avec 3 listbox,service bâtiment et étage (pour prendre un autre exemple on pourrais assimile cela a lb1:nom du double album, lb2 nom du cd et enfin lb3 titre des chansons).
en cliquant sur un service on a les batiments qui s affichent dans lb2 ensuite en cliquant sur l'un des batiments on a une liste d'étages.

je peux le faire a partir de sauvegarde en fichier texte avec
index , et le nom
puis un affichage dans lb2 des données correspondant a index du lb1
etc.
mais existe t'il methode un peu moins 'basique' et plus delphienne

voila, en espérant avoir été clair,
a bientôt

8 réponses

dubois77 Messages postés 675 Date d'inscription jeudi 17 avril 2008 Statut Membre Dernière intervention 19 février 2019 14
2 janv. 2010 à 15:51
Ci joint à cette adresse une application qui répond (peut être) à ta question
http://sports.roissy.free.fr/delphi/Grod0026.zip
Dubois77
3
cs_Delphiprog Messages postés 4297 Date d'inscription samedi 19 janvier 2002 Statut Membre Dernière intervention 9 janvier 2013 32
20 déc. 2009 à 10:46
Bonjour grod0026,

Si ça fonctionne ainsi, pourquoi vouloir changer ?

8000 Lévriers 'galgos' par an sont torturés et massacrés en Espagne
May Delphi be with you

Pensez à cliquer sur Réponse acceptée lorsque la réponse vous convient.
0
Bacterius Messages postés 3792 Date d'inscription samedi 22 décembre 2007 Statut Membre Dernière intervention 3 juin 2016 10
20 déc. 2009 à 12:31
Qu'entends-tu par solution "delphienne" ? Peux-tu donner un exemple, ou détailler ?

Cordialement, Bacterius !
0
Caribensila Messages postés 2527 Date d'inscription jeudi 15 janvier 2004 Statut Membre Dernière intervention 16 octobre 2019 18
20 déc. 2009 à 17:55
Salut,

Il y a TCollection pour les listes complexes.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
grod0026 Messages postés 141 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 22 septembre 2023
1 janv. 2010 à 15:19
bonjour,
désolé pour le temps de réponse un peu long,
voila le code :
unit Unit1;
//
// grod0026@free.fr le 01/01/2010
//
//
// Quelques petites remarques
// - je stocke dans le fichier le numéro (ici de 1 a 11) qui ne sert
// qu'a la lisibilité du fichier texte ou sont enregistré les données.
// - pour les grandes listes on préférera utiliser des tableaux plutôt
// des accès a un fichier, surtout que celui ci est un fichier texte
// - l ajout ou la suppression ( boutons + et -) ne sont pas faits
// ainsi que l'enregistrement de nouvelles valeurs.
// - pour le moment l'équivalent graphique est "figé" dans un stinggrid
// dans un développement futur rien n empêche la lecture des données
// puis création automatique.
// - fichier texte peut être un fichier a accès séquentiel.
// - la structure du fichier peut être modifié du genre
// nom , n°combo ,lien
// - on fait deux procédures de recherche qui peuvent etre reduite a 1
// seule
//
//
//
//
// structure des données enregistrés dans 'c:\CB1Cb.txt'
// numéro | nom | N° combo |lien service | lien bâtiment
// 1 | service1 | 1 | 0 | 0
// 2 | batmentA | 2 | 1 | 0
// 3 | etage 01 | 3 | 1 | 2
// 4 | batimentB | 2 | 1 | 0
// 5 | service2 | 1 | 0 | 0
// 6 | etage03 | 3 | 1 | 4
// 7 | batimentC | 2 | 5 | 0
// 8 | etage04 | 3 | 5 | 7
// 9 | etage05 | 3 | 5 | 7
// 10 etage06 | 3 | 5 | 7
// 11 etage02 | 3 | 1 | 2
//
// equivaut a
//
// service1 -> batimentA -> etage01
// -> etage02
// -> batimentB -> etage03
//
// service2 -> batimentC -> etage04
// -> etage05
// -> etage06
//
//


interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, StdCtrls, ShellApi, Menus, Mask, Grids;

var
FlistBox : TextFile;

type
TForm1 = class(TForm)
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Etotal: TEdit;
CB1: TComboBox;
CB2: TComboBox;
CB3: TComboBox;
BAjoutCB1: TButton;
MemoCB1: TMemo;
MemoCB2: TMemo;
MemoCB3: TMemo;
sg1: TStringGrid;
Label13: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
b6: TButton;
Button5: TButton;
procedure BAjoutCB1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CB1Click(Sender: TObject);
procedure CB2Click(Sender: TObject);
private
{ Déclarations privées }

public
{ Déclarations publiques }

end;

var
Form1: TForm1;
comboBox : TComboBox;
pointCB1 : integer; // valeur choisie dans Cb 1
pointCB2 : integer; // valeur choisie dans Cb 2
pointCB3 : integer; // valeur choisie dans Cb 3
TextaLire : string;
total : string;
rubri : array[1..5,1..100] of string;
// les valeurs text 1 a 5 les champs et 1 a 100 les valeurs
totfi : integer; (* raz puis nombre total de valeurs lues dans le fichier *)
Narech2 : integer; // num a rechercher pour cb2
Narech3 : integer; // num a rechercher pour cb3

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
// a la creation on ne cherche les donnees que du Combo Box 1
// les autres combo seront remplis avec les donnees du cb precedent
var j: integer;
Textmemo1 : string[200];
begin
cb1.Clear;
If FileExists('c:\CB1Cb.txt') then
begin
AssignFile(Flistbox,'c:\CB1Cb.txt');
reset(Flistbox);
CB1.Clear;
CB2.Clear;
CB3.Clear;
cb2.Enabled:=false;
cb3.Enabled:=false;
total:='';
totfi :=0;
while not Eof(Flistbox) do
begin
Textmemo1:='';
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
rubri[j,totfi]:=TextaLire;
Textmemo1:=Textmemo1+TextaLire+' ';
end;
if rubri[3,totfi] = '1' then
begin;
CB1.Items.Add(rubri[2,totfi]);
memoCB1.Lines.Add(rubri[2,totfi]);
end;
inc(totfi);
end;
closefile(flistbox);
end;
sg1.ColCount:=4;
sg1.RowCount:=7;
sg1.Cells[1,1]:='service 1 -->';sg1.Cells[2,1]:='batiment A -->';
sg1.Cells[3,1]:='Etage01';
sg1.Cells[2,2]:=' -->';sg1.Cells[3,2]:='Etage02';
sg1.Cells[1,3]:=' -->';
sg1.Cells[2,3]:='batiment B -->';sg1.Cells[3,3]:='Etage03';
sg1.Cells[1,4]:='service 2 -->';sg1.Cells[2,4]:='batiment C -->';
sg1.Cells[3,4]:='Etage04';sg1.Cells[3,5]:='Etage05';sg1.Cells[3,6]:='Etage06';
end;

procedure TForm1.BAjoutCB1Click(Sender: TObject);
var
ligne : string;
begin
ligne:= InputBox('Nouveau COMBOBox', 'entrez le nom', '');
if ligne<>'' then
CB1.Items.Add(ligne);
// on sauvegarde
end;

procedure TForm1.CB1Click(Sender: TObject);// Click
var
j : integer;
i : integer;
Textmemo2 : string[200];
aRech : string[200];

begin
Cb2.Clear;
cb2.Enabled:=true;
Cb3.Clear;
cb3.Enabled:=False;
combobox := TCombobox(Sender);
pointCB1:= CB1.ItemIndex;// indique l indice de l element
total :=combobox.Items[pointCB1];
Etotal.Text:=total;
aRech:=total;Narech2:=0;
i:=0;
If FileExists('c:\CB1Cb.txt') then
begin
AssignFile(Flistbox,'c:\CB1Cb.txt');
reset(Flistbox);
i:=0 ;
// on recherche a quel item correspont arech
while not eof(Flistbox) do
begin
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
if j=2 then
if TextaLire = aRech then Narech2:=i+1;
end;
inc(i);
end;
reset(Flistbox);//se remet au debut
memoCB2.Clear;
i:=0; // puis on recherche
while not Eof(Flistbox) do
begin
Textmemo2:='';
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
Textmemo2:=Textmemo2+TextaLire+' ';
rubri[j,i]:=Textalire;
end;
if rubri[3,i]='2' then
begin
if rubri[4,i]=inttostr(Narech2) then
begin
memoCB2.Lines.Add(rubri[2,i]);
CB2.Items.Add(rubri[2,i]);
end;
End;
inc(i);
End;
end;
end;

procedure TForm1.CB2Click(Sender: TObject);
var
j : integer;
i : integer;
Textmemo2 : string[200];
aRech : string[200];

begin

CB3.Clear;
CB3.Enabled:=true;
memoCB3.Clear;
combobox := TCombobox(Sender);
pointCB2:= CB2.ItemIndex;// indique l indice de l element
total :=combobox.Items[pointCB2];
Etotal.Text:=total;
aRech:=total;Narech3:=0;
i:=0;
If FileExists('c:\CB1Cb.txt') then
begin
AssignFile(Flistbox,'c:\CB1Cb.txt');
reset(Flistbox);
i:=0 ;
// on recherche a quel item correspont arech
while not eof(Flistbox) do
begin
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
if j=2 then
if TextaLire = aRech then Narech3:=i+1;
end;
inc(i);
end;
reset(Flistbox);//se remet au debut
i:=0;
while not Eof(Flistbox) do
begin
Textmemo2:='';
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
Textmemo2:=Textmemo2+TextaLire+' ';
rubri[j,i]:=Textalire;
end;
if rubri[3,i]='3' then
begin
if rubri[5,i]=inttostr(Narech3) then
begin
memoCB3.Lines.Add(rubri[2,i]);
CB3.Items.Add(rubri[2,i]);
end;
End;
inc(i);
End;
end;
end;
begin
end.

voila, encore quelques modifications a faire et voire pour tcollection
a +
0
grod0026 Messages postés 141 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 22 septembre 2023
1 janv. 2010 à 15:21
re,
a propos
bonne année 2010 a tous
a+
ps desole pour l indentation qui a disparue
au revoir

unit Unit1;

//
// grod0026@free.fr le 01/01/2010
//
//
// Quelques petites remarques
// - je stocke dans le fichier le numero (ici de 1 a 11) qui ne sert qu'a la
// lisibilité du fichier texte ou sont enregistré les donnéés.
// - pour les grandes listes on preferera utiliser des tableaux plutot des
// acces a un fichier, surtout que celui ci est un fichier texte
// - l ajout ou la suppression ( boutons + et -) ne sont pas faits ainsi que
// l'enregistrement de nouvelles valeurs.
// - pour le moment l equivalent graphique est "figé" dans un stinggrid
// dans un devellopement futur rien n empeche la lecture des donnees
// puis création automatique.
// - fichier texte peut etre un fichier a acces sequentiel.
// - la structure du fichier peut etre modifié du genre
// nom , n°combo ,lien
// - on fait deux procedures de recherche qui peut etre reduite a 1 seule
//
//
//
//
// strucure des données enregistrés dans 'c:\CB1Cb.txt'
// numero | nom | N° combo |lien service | lien batiment
// 1 | service1 | 1 | 0 | 0
// 2 | batmentA | 2 | 1 | 0
// 3 | etage 01 | 3 | 1 | 2
// 4 | batimentB | 2 | 1 | 0
// 5 | service2 | 1 | 0 | 0
// 6 | etage03 | 3 | 1 | 4
// 7 | batimentC | 2 | 5 | 0
// 8 | etage04 | 3 | 5 | 7
// 9 | etage05 | 3 | 5 | 7
// 10 etage06 | 3 | 5 | 7
// 11 etage02 | 3 | 1 | 2
//
// equivaut a
//
// service1 -> batimentA -> etage01
// -> etage02
// -> batimentB -> etage03
//
// service2 -> batimentC -> etage04
// -> etage05
// -> etage06
//
//


interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, StdCtrls, ShellApi, Menus, Mask, Grids;

var
FlistBox : TextFile;

type
TForm1 = class(TForm)
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Etotal: TEdit;
CB1: TComboBox;
CB2: TComboBox;
CB3: TComboBox;
BAjoutCB1: TButton;
MemoCB1: TMemo;
MemoCB2: TMemo;
MemoCB3: TMemo;
sg1: TStringGrid;
Label13: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
b6: TButton;
Button5: TButton;
procedure BAjoutCB1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CB1Click(Sender: TObject);
procedure CB2Click(Sender: TObject);
private
{ Déclarations privées }

public
{ Déclarations publiques }

end;

var
Form1: TForm1;
comboBox : TComboBox;
pointCB1 : integer; // valeur choisie dans Cb 1
pointCB2 : integer; // valeur choisie dans Cb 2
pointCB3 : integer; // valeur choisie dans Cb 3
TextaLire : string;
total : string;
rubri : array[1..5,1..100] of string;
// les valeurs text 1 a 5 les champs et 1 a 100 les valeurs
totfi : integer; (* raz puis nombre total de valeurs lues dans le fichier *)
Narech2 : integer; // num a rechercher pour cb2
Narech3 : integer; // num a rechercher pour cb3

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
// a la creation on ne cherche les donnees que du Combo Box 1
// les autres combo seront remplis avec les donnees du cb precedent
var j: integer;
Textmemo1 : string[200];
begin
cb1.Clear;
If FileExists('c:\CB1Cb.txt') then
begin
AssignFile(Flistbox,'c:\CB1Cb.txt');
reset(Flistbox);
CB1.Clear;
CB2.Clear;
CB3.Clear;
cb2.Enabled:=false;
cb3.Enabled:=false;
total:='';
totfi :=0;
while not Eof(Flistbox) do
begin
Textmemo1:='';
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
rubri[j,totfi]:=TextaLire;
Textmemo1:=Textmemo1+TextaLire+' ';
end;
if rubri[3,totfi] = '1' then
begin;
CB1.Items.Add(rubri[2,totfi]);
memoCB1.Lines.Add(rubri[2,totfi]);
end;
inc(totfi);
end;
closefile(flistbox);
end;
sg1.ColCount:=4;
sg1.RowCount:=7;
sg1.Cells[1,1]:='service 1 -->';sg1.Cells[2,1]:='batiment A -->';
sg1.Cells[3,1]:='Etage01';
sg1.Cells[2,2]:=' -->';sg1.Cells[3,2]:='Etage02';
sg1.Cells[1,3]:=' -->';
sg1.Cells[2,3]:='batiment B -->';sg1.Cells[3,3]:='Etage03';
sg1.Cells[1,4]:='service 2 -->';sg1.Cells[2,4]:='batiment C -->';
sg1.Cells[3,4]:='Etage04';sg1.Cells[3,5]:='Etage05';sg1.Cells[3,6]:='Etage06';
end;

procedure TForm1.BAjoutCB1Click(Sender: TObject);
var
ligne : string;
begin
ligne:= InputBox('Nouveau COMBOBox', 'entrez le nom', '');
if ligne<>'' then
CB1.Items.Add(ligne);
// on sauvegarde
end;

procedure TForm1.CB1Click(Sender: TObject);// Click
var
j : integer;
i : integer;
Textmemo2 : string[200];
aRech : string[200];

begin
Cb2.Clear;
cb2.Enabled:=true;
Cb3.Clear;
cb3.Enabled:=False;
combobox := TCombobox(Sender);
pointCB1:= CB1.ItemIndex;// indique l indice de l element
total :=combobox.Items[pointCB1];
Etotal.Text:=total;
aRech:=total;Narech2:=0;
i:=0;
If FileExists('c:\CB1Cb.txt') then
begin
AssignFile(Flistbox,'c:\CB1Cb.txt');
reset(Flistbox);
i:=0 ;
// on recherche a quel item correspont arech
while not eof(Flistbox) do
begin
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
if j=2 then
if TextaLire = aRech then Narech2:=i+1;
end;
inc(i);
end;
reset(Flistbox);//se remet au debut
memoCB2.Clear;
i:=0; // puis on recherche
while not Eof(Flistbox) do
begin
Textmemo2:='';
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
Textmemo2:=Textmemo2+TextaLire+' ';
rubri[j,i]:=Textalire;
end;
if rubri[3,i]='2' then
begin
if rubri[4,i]=inttostr(Narech2) then
begin
memoCB2.Lines.Add(rubri[2,i]);
CB2.Items.Add(rubri[2,i]);
end;
End;
inc(i);
End;
end;
end;

procedure TForm1.CB2Click(Sender: TObject);
var
j : integer;
i : integer;
Textmemo2 : string[200];
aRech : string[200];

begin

CB3.Clear;
CB3.Enabled:=true;
memoCB3.Clear;
combobox := TCombobox(Sender);
pointCB2:= CB2.ItemIndex;// indique l indice de l element
total :=combobox.Items[pointCB2];
Etotal.Text:=total;
aRech:=total;Narech3:=0;
i:=0;
If FileExists('c:\CB1Cb.txt') then
begin
AssignFile(Flistbox,'c:\CB1Cb.txt');
reset(Flistbox);
i:=0 ;
// on recherche a quel item correspont arech
while not eof(Flistbox) do
begin
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
if j=2 then
if TextaLire = aRech then Narech3:=i+1;
end;
inc(i);
end;
reset(Flistbox);//se remet au debut
i:=0;
while not Eof(Flistbox) do
begin
Textmemo2:='';
for j :=1 to 5 do
begin
readln(flistbox,TextaLire);
Textmemo2:=Textmemo2+TextaLire+' ';
rubri[j,i]:=Textalire;
end;
if rubri[3,i]='3' then
begin
if rubri[5,i]=inttostr(Narech3) then
begin
memoCB3.Lines.Add(rubri[2,i]);
CB3.Items.Add(rubri[2,i]);
end;
End;
inc(i);
End;
end;
end;
begin
end.
0
cs_Delphiprog Messages postés 4297 Date d'inscription samedi 19 janvier 2002 Statut Membre Dernière intervention 9 janvier 2013 32
2 janv. 2010 à 09:56
@grod0026 : "desole pour l indentation qui a disparue "
Au cas où tu ne l'aurais pas vu, il y a un bouton dans la rangée au dessus de la boite d'édition qui sert à formater du code.
Voici donc le code formaté pour éviter à mes petits camarades de perdre du temps et faciliter la lecture à tous :

unit Unit1;
//
// grod0026@free.fr le 01/01/2010
//
//
// Quelques petites remarques
// - je stocke dans le fichier le numero (ici de 1 a 11) qui ne sert qu'a la
// lisibilité du fichier texte ou sont enregistré les donnéés.
// - pour les grandes listes on preferera utiliser des tableaux plutot des
// acces a un fichier, surtout que celui ci est un fichier texte
// - l ajout ou la suppression ( boutons + et -) ne sont pas faits ainsi que
// l'enregistrement de nouvelles valeurs.
// - pour le moment l equivalent graphique est "figé" dans un stinggrid
// dans un devellopement futur rien n empeche la lecture des donnees
// puis création automatique.
// - fichier texte peut etre un fichier a acces sequentiel.
// - la structure du fichier peut etre modifié du genre
// nom , n°combo ,lien
// - on fait deux procedures de recherche qui peut etre reduite a 1 seule
//
//
//
//
// strucure des données enregistrés dans 'c:\CB1Cb.txt'
// numero | nom | N° combo |lien service | lien batiment
// 1 | service1 | 1 | 0 | 0
// 2 | batmentA | 2 | 1 | 0
// 3 | etage 01 | 3 | 1 | 2
// 4 | batimentB | 2 | 1 | 0
// 5 | service2 | 1 | 0 | 0
// 6 | etage03 | 3 | 1 | 4
// 7 | batimentC | 2 | 5 | 0
// 8 | etage04 | 3 | 5 | 7
// 9 | etage05 | 3 | 5 | 7
// 10 etage06 | 3 | 5 | 7
// 11 etage02 | 3 | 1 | 2
//
// equivaut a
//
// service1 -> batimentA -> etage01
// -> etage02
// -> batimentB -> etage03
//
// service2 -> batimentC -> etage04
// -> etage05
// -> etage06
//
//


interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, jpeg, StdCtrls, ShellApi, Menus, Mask, Grids;

var
  FlistBox: TextFile;

type
  TForm1 = class(TForm)
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Etotal: TEdit;
    CB1: TComboBox;
    CB2: TComboBox;
    CB3: TComboBox;
    BAjoutCB1: TButton;
    MemoCB1: TMemo;
    MemoCB2: TMemo;
    MemoCB3: TMemo;
    sg1: TStringGrid;
    Label13: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    b6: TButton;
    Button5: TButton;
    procedure BAjoutCB1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure CB1Click(Sender: TObject);
    procedure CB2Click(Sender: TObject);
  private
{ Déclarations privées }

  public
{ Déclarations publiques }

  end;

var
  Form1: TForm1;
  comboBox: TComboBox;
  pointCB1: integer; // valeur choisie dans Cb 1
  pointCB2: integer; // valeur choisie dans Cb 2
  pointCB3: integer; // valeur choisie dans Cb 3
  TextaLire: string;
  total: string;
  rubri: array[1..5, 1..100] of string;
// les valeurs text 1 a 5 les champs et 1 a 100 les valeurs
  totfi: integer; (* raz puis nombre total de valeurs lues dans le fichier *)
  Narech2: integer; // num a rechercher pour cb2
  Narech3: integer; // num a rechercher pour cb3

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
// a la creation on ne cherche les donnees que du Combo Box 1
// les autres combo seront remplis avec les donnees du cb precedent
var j: integer;
  Textmemo1: string[200];
begin
  cb1.Clear;
  if FileExists('c:\CB1Cb.txt') then
  begin
    AssignFile(Flistbox, 'c:\CB1Cb.txt');
    reset(Flistbox);
    CB1.Clear;
    CB2.Clear;
    CB3.Clear;
    cb2.Enabled := false;
    cb3.Enabled := false;
    total := '';
    totfi := 0;
    while not Eof(Flistbox) do
    begin
      Textmemo1 := '';
      for j := 1 to 5 do
      begin
        readln(flistbox, TextaLire);
        rubri[j, totfi] := TextaLire;
        Textmemo1 := Textmemo1 + TextaLire + ' ';
      end;
      if rubri[3, totfi] = '1' then
      begin;
        CB1.Items.Add(rubri[2, totfi]);
        memoCB1.Lines.Add(rubri[2, totfi]);
      end;
      inc(totfi);
    end;
    closefile(flistbox);
  end;
  sg1.ColCount := 4;
  sg1.RowCount := 7;
  sg1.Cells[1, 1] := 'service 1 -->'; sg1.Cells[2, 1] := 'batiment A -->';
  sg1.Cells[3, 1] := 'Etage01';
  sg1.Cells[2, 2] := ' -->'; sg1.Cells[3, 2] := 'Etage02';
  sg1.Cells[1, 3] := ' -->';
  sg1.Cells[2, 3] := 'batiment B -->'; sg1.Cells[3, 3] := 'Etage03';
  sg1.Cells[1, 4] := 'service 2 -->'; sg1.Cells[2, 4] := 'batiment C -->';
  sg1.Cells[3, 4] := 'Etage04'; sg1.Cells[3, 5] := 'Etage05'; sg1.Cells[3, 6] := 'Etage06';
end;

procedure TForm1.BAjoutCB1Click(Sender: TObject);
var
  ligne: string;
begin
  ligne := InputBox('Nouveau COMBOBox', 'entrez le nom', '');
  if ligne <> '' then
    CB1.Items.Add(ligne);
// on sauvegarde
end;

procedure TForm1.CB1Click(Sender: TObject); // Click
var
  j: integer;
  i: integer;
  Textmemo2: string[200];
  aRech: string[200];

begin
  Cb2.Clear;
  cb2.Enabled := true;
  Cb3.Clear;
  cb3.Enabled := False;
  combobox := TCombobox(Sender);
  pointCB1 := CB1.ItemIndex; // indique l indice de l element
  total := combobox.Items[pointCB1];
  Etotal.Text := total;
  aRech := total; Narech2 := 0;
  i := 0;
  if FileExists('c:\CB1Cb.txt') then
  begin
    AssignFile(Flistbox, 'c:\CB1Cb.txt');
    reset(Flistbox);
    i := 0;
// on recherche a quel item correspont arech
    while not eof(Flistbox) do
    begin
      for j := 1 to 5 do
      begin
        readln(flistbox, TextaLire);
        if j = 2 then
          if TextaLire = aRech then Narech2 := i + 1;
      end;
      inc(i);
    end;
    reset(Flistbox); //se remet au debut
    memoCB2.Clear;
    i := 0; // puis on recherche
    while not Eof(Flistbox) do
    begin
      Textmemo2 := '';
      for j := 1 to 5 do
      begin
        readln(flistbox, TextaLire);
        Textmemo2 := Textmemo2 + TextaLire + ' ';
        rubri[j, i] := Textalire;
      end;
      if rubri[3, i] = '2' then
      begin
        if rubri[4, i] = inttostr(Narech2) then
        begin
          memoCB2.Lines.Add(rubri[2, i]);
          CB2.Items.Add(rubri[2, i]);
        end;
      end;
      inc(i);
    end;
  end;
end;

procedure TForm1.CB2Click(Sender: TObject);
var
  j: integer;
  i: integer;
  Textmemo2: string[200];
  aRech: string[200];

begin

  CB3.Clear;
  CB3.Enabled := true;
  memoCB3.Clear;
  combobox := TCombobox(Sender);
  pointCB2 := CB2.ItemIndex; // indique l indice de l element
  total := combobox.Items[pointCB2];
  Etotal.Text := total;
  aRech := total; Narech3 := 0;
  i := 0;
  if FileExists('c:\CB1Cb.txt') then
  begin
    AssignFile(Flistbox, 'c:\CB1Cb.txt');
    reset(Flistbox);
    i := 0;
// on recherche a quel item correspont arech
    while not eof(Flistbox) do
    begin
      for j := 1 to 5 do
      begin
        readln(flistbox, TextaLire);
        if j = 2 then
          if TextaLire = aRech then Narech3 := i + 1;
      end;
      inc(i);
    end;
    reset(Flistbox); //se remet au debut
    i := 0;
    while not Eof(Flistbox) do
    begin
      Textmemo2 := '';
      for j := 1 to 5 do
      begin
        readln(flistbox, TextaLire);
        Textmemo2 := Textmemo2 + TextaLire + ' ';
        rubri[j, i] := Textalire;
      end;
      if rubri[3, i] = '3' then
      begin
        if rubri[5, i] = inttostr(Narech3) then
        begin
          memoCB3.Lines.Add(rubri[2, i]);
          CB3.Items.Add(rubri[2, i]);
        end;
      end;
      inc(i);
    end;
  end;
end;
begin
end.



8000 Lévriers 'galgos' par an sont torturés et massacrés en Espagne
May Delphi be with you

Pensez à cliquer sur Réponse acceptée lorsque la réponse vous convient.
0
grod0026 Messages postés 141 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 22 septembre 2023
2 janv. 2010 à 22:34
bonsoir a tous,
tout d abord merci a Delphiprog d avoir indenté le prog.
et encore merci a Dubois77 pour ce programme qui correspond totalement a ce que j attendais.
encore merci
a bientot
0
Rejoignez-nous