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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| Option Explicit
Dim T As Integer
Dim Existe As Boolean
Dim SourceListe As ListBox
Private Sub Form_Load()
List2.OLEDragMode = 1
List3.OLEDragMode = 1
List2.OLEDropMode = 1
List3.OLEDropMode = 1
List1.Clear
For T = 1 To 5
List1.AddItem T & " fois"
Next T
End Sub
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
List1.OLEDrag
End Sub
Private Sub List1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
'Se produit lorsqu'une opération glisser-déplacer OLE est initialisée manuellement ou automatiquement.
AllowedEffects = vbDropEffectCopy
Data.Clear
Data.SetData List1.Text, vbCFText 'format texte
Set SourceListe = List1
End Sub
'----------------------------------------------------------------------------------------------------
Private Sub List2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If List2.Text <> "" Then List2.OLEDrag
End Sub
Private Sub List2_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
'Se produit lorsqu'une opération glisser-déplacer OLE est initialisée manuellement ou automatiquement.
'AllowedEffects = vbDropEffectMove
Data.Clear
Data.SetData List2.Text, vbCFText 'format texte
Set SourceListe = List2
End Sub
Private Sub List2_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
'Se produit lorsque des données sont déposées sur un contrôle à l'aide d'une
'opération glisser-déplacer OLE, alors que OLEDropMode a la valeur Manual.
Existe = False
For T = 0 To List2.ListCount - 1
If List2.List(T) = Data.GetData(vbCFText) Then Existe = True
Next T
If Existe = False Then
List2.AddItem Data.GetData(vbCFText)
If SourceListe.Name <> "List1" And SourceListe.Name <> "List2" Then SourceListe.RemoveItem (SourceListe.ListIndex)
End If
Set SourceListe = Nothing
End Sub
'----------------------------------------------------------------------------------------------------
Private Sub List3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If List3.Text <> "" Then List3.OLEDrag
End Sub
Private Sub List3_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
'Se produit lorsqu'une opération glisser-déplacer OLE est initialisée manuellement ou automatiquement.
'AllowedEffects = vbDropEffectMove
Data.Clear
Data.SetData List3.Text, vbCFText 'format texte
Set SourceListe = List3
End Sub
Private Sub List3_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
'Se produit lorsque des données sont déposées sur un contrôle à l'aide d'une
'opération glisser-déplacer OLE, alors que OLEDropMode a la valeur Manual.
Existe = False
For T = 0 To List3.ListCount - 1
If List3.List(T) = Data.GetData(vbCFText) Then Existe = True
Next T
If Existe = False Then
List3.AddItem Data.GetData(vbCFText)
If SourceListe.Name <> "List1" And SourceListe.Name <> "List3" Then SourceListe.RemoveItem (SourceListe.ListIndex)
End If
Set SourceListe = Nothing
End Sub |
Partager