OVH Cloud OVH Cloud

Drag and Drop

1 réponse
Avatar
Salva
j'ai deux Listes sur une même form, et je voudrais par un
glisser-déplacer copier la une donnee dea la 1° liste dans la 2° liste.
Comment faire ? Quelles sont les propriétés et les évènements à définir ?
Merci pour votre aide.
Salutations.

1 réponse

Avatar
ng
Salut,

Voici un exemple tout simple à améliorer :

Private Sub Form_Load()

'//List 1 :
'// Propriétés
'// DragMode = 0
'// DragIcon = [Icone au choix]

Dim i As Integer
Call Randomize(Timer)
For i = 1 To 10
Call List1.AddItem("Item #" & i & " : " & Int(Rnd * 2000 + 1001))
Call List2.AddItem("Item #" & i & " : " & Int(Rnd * 2000 + 1001))
Next
End Sub

Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Call List1.Drag(vbBeginDrag)
End Sub

Private Sub List2_DragDrop(Source As Control, X As Single, Y As Single)
Call List2.AddItem(List1.Text)
Call List1.RemoveItem(List1.ListIndex)
Call List1.Drag(vbEndDrag)
End Sub


--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

Salva wrote:
j'ai deux Listes sur une même form, et je voudrais par un
glisser-déplacer copier la une donnee dea la 1° liste dans la 2°
liste. Comment faire ? Quelles sont les propriétés et les évènements
à définir ? Merci pour votre aide.
Salutations.