2 listbox : comment passer les données de l'une à l'autre ?

cs_Filou07 Messages postés 43 Date d'inscription mercredi 16 janvier 2002 Statut Membre Dernière intervention 29 février 2008 - 21 mai 2002 à 13:09
cs_Filou07 Messages postés 43 Date d'inscription mercredi 16 janvier 2002 Statut Membre Dernière intervention 29 février 2008 - 21 mai 2002 à 14:58
Salut,

J'ai deux listbox : la première contient les enregistrements d'une base de données dans laquelle on peut sélectionner un ou +sieurs éléments qui vont remplir la deuxième listbox quand on clique sur un bouton.

SVP DISEZ MOI COMMENT ON FAIT ???????
Filou07 :question)

2 réponses

cs_Juju42 Messages postés 8 Date d'inscription mardi 21 mai 2002 Statut Membre Dernière intervention 1 août 2002
21 mai 2002 à 14:18
Tiens, cela pourrait t'aider.
Attention, il y aussi un tri...

Private Sub AddButton_Click()
Dim BoxFrom, BoxTo As Object
Set BoxFrom = List1Name
Set BoxTo = List2Name
Sortlist BoxFrom, BoxTo
End Sub

Private Sub RemoveButton_Click()
Dim BoxFrom, BoxTo As Object
Set BoxFrom = List2Name
Set BoxTo = List1Name
Sortlist BoxFrom, BoxTo
End Sub

Function Sortlist(BoxFrom, BoxTo)

If BoxFrom.ListIndex = -1 Then
Exit Function
Else
Item = BoxFrom.Text
If BoxTo.ListCount = 0 Then
BoxTo.AddItem Item, i
BoxFrom.RemoveItem BoxFrom.ListIndex
Else
BoxTo.AddItem Item
BoxFrom.RemoveItem BoxFrom.ListIndex
Counti = BoxTo.ListCount - 1
If BoxFrom.Name <> "SortBox" Or BoxFrom.Name <> "SortBox2" Then
For i = Counti To 0 Step -1
For j = i - 1 To 0 Step -1
Item = BoxTo.List(j)
Comp = BoxTo.List(i)
If Item > Comp Then
BoxTo.RemoveItem j
BoxTo.AddItem Item, i
End If
Next j
Next i
End If
End If
End If
End Function
0
cs_Filou07 Messages postés 43 Date d'inscription mercredi 16 janvier 2002 Statut Membre Dernière intervention 29 février 2008 3
21 mai 2002 à 14:58
Merci bcp, je vais tout de suite l'essayer !!
Filou07
0
Rejoignez-nous