Listboxs et ascenseurs synchro

Résolu
cs_TouTSpeed Messages postés 72 Date d'inscription jeudi 5 janvier 2006 Statut Membre Dernière intervention 30 août 2007 - 30 juin 2006 à 21:10
japee Messages postés 1727 Date d'inscription vendredi 27 décembre 2002 Statut Modérateur Dernière intervention 6 novembre 2021 - 1 juil. 2006 à 12:10
bonjour,


je travail sous delphi 6,


voila j'ai plusieurs listbox (6) et je voudrais que l'ascenseur de
chaque listbox bouge en même temps et soit donc toujours au même niveau
dans chaque listbox , je précise qu'il y a le même nombre d'élément
dans chaque listbox .


je vous en remerci par avance si vous avez la solution !

7 réponses

cs_TouTSpeed Messages postés 72 Date d'inscription jeudi 5 janvier 2006 Statut Membre Dernière intervention 30 août 2007
1 juil. 2006 à 10:22
merci à toi jlen


c'est exactement ce qu'il me fallait !


donc pour la synchronistaion il suffit de faire


 "ListBox2.TopIndex:=ListBox1.TopIndex;"


dans l'évènement onclick de la listbox 1 


ce qui donne ceci pour une synchronisation de 6 listbox par rapport a la première


procedure TForm1.ListBox1Click(Sender: TObject);

begin

ListBox2.TopIndex:=ListBox1.TopIndex;

ListBox3.TopIndex:=ListBox2.TopIndex;

ListBox4.TopIndex:=ListBox3.TopIndex;

ListBox5.TopIndex:=ListBox4.TopIndex;

ListBox6.TopIndex:=ListBox5.TopIndex;

end;
3
Utilisateur anonyme
1 juil. 2006 à 11:18
Salut,

Ceci serait beaucoup mieux

procedure TForm1.ListBox1Click(Sender: TObject);
Var
i : integer;
begin
i:=ListBox1.TopIndex;
ListBox2.TopIndex:=i;
ListBox3.TopIndex:=i;
ListBox4.TopIndex:=i;
ListBox5.TopIndex:=i;
ListBox6.TopIndex:=i;
end;

Et en cherchant tu pourrais faire mieux : ;).
3
japee Messages postés 1727 Date d'inscription vendredi 27 décembre 2002 Statut Modérateur Dernière intervention 6 novembre 2021 8
1 juil. 2006 à 11:58
Bon jour,

tu peux faire ainsi :

for j := 2 to 6 do
  TListBox(FindComponent('ListBox'+ IntToStr(i))).TopIndex := i;

Bonne prog' !
3
cs_TouTSpeed Messages postés 72 Date d'inscription jeudi 5 janvier 2006 Statut Membre Dernière intervention 30 août 2007
1 juil. 2006 à 11:27
procedure TForm1.ListBox1Click(Sender: TObject);
Var
i : integer;
begin
i:=ListBox1.TopIndex;
ListBox2.TopIndex:=i;
ListBox3.TopIndex:=i;
ListBox4.TopIndex:=i;
ListBox5.TopIndex:=i;
ListBox6.TopIndex:=i;
end;

oui effectivement j'ai pensé aussi a ceci

procedure TForm1.ListBox1Click(Sender: TObject);
Var
i : integer;
j : integer;
begin
i:=ListBox1.TopIndex;

for j : = 2 to 6 do
begin
ListBox[j].TopIndex:=i;   // instruction qui n'existe pas mais a mon avis mon idée
end;                                //est possible , mais je débute !
end;

Si quelqu'un sait comment faire pour passer d'une listbox1 à 2 par une variable qu'il le dise !

merci
0

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

Posez votre question
cs_TouTSpeed Messages postés 72 Date d'inscription jeudi 5 janvier 2006 Statut Membre Dernière intervention 30 août 2007
1 juil. 2006 à 12:00
merci beaucoup je savais qu'on pouvait le faire mais comment ? maintenant je sais!
0
cs_TouTSpeed Messages postés 72 Date d'inscription jeudi 5 janvier 2006 Statut Membre Dernière intervention 30 août 2007
1 juil. 2006 à 12:03
donc au final

procedure TForm1.ListBox1Click(Sender: TObject);
Var
i : integer;
j : integer;
begin
i:=ListBox1.TopIndex;


for j := 2 to 6 do
  TListBox(FindComponent('ListBox'+ IntToStr(   j  "pas i "      ))).TopIndex := i;


end;

merci à vous tous et bonne prog
0
japee Messages postés 1727 Date d'inscription vendredi 27 décembre 2002 Statut Modérateur Dernière intervention 6 novembre 2021 8
1 juil. 2006 à 12:10
Exact !

J'ai confondu vitesse et précipitation, comme tu peux le voir
(j'ai été too speed, quoi, lol...)

Bonne prog'
0
Rejoignez-nous