Comment peut on faire pour deplacer un objet d'une liste
box a 2 colonne vers une autre ?
ex :
listbox1 listbox2
essai1 choix1
essai2 choix2
essai3 choix3
j'aimerai par drag n drop avoir
listbox1 listbox2
essai1 choix1 essai2 choix2
essai3 choix3
voici le code que j'utilise mais je ne sais pas qu'elle
mofdif il faut faire pour qu'il prenne en compte les deux
colonnes.
merci d'avance
Private Sub ListBox2_BeforeDragOver(ByVal Cancel As _
MSForms.ReturnBoolean, ByVal Data As _
MSForms.DataObject, ByVal X As Single, _
ByVal Y As Single, ByVal DragState As Long, _
ByVal Effect As MSForms.ReturnEffect, _
ByVal Shift As Integer)
Cancel = True
Effect = 1
End Sub
Private Sub ListBox2_BeforeDropOrPaste(ByVal _
Cancel As MSForms.ReturnBoolean, _
ByVal Action As Long, ByVal Data As _
MSForms.DataObject, ByVal X As Single, _
ByVal Y As Single, ByVal Effect As _
MSForms.ReturnEffect, ByVal Shift As Integer)
Cancel = True
Effect = 1
ListBox2.AddItem Data.GetText
End Sub
Private Sub ListBox1_MouseMove(ByVal Button As _
Integer, ByVal Shift As Integer, ByVal X As _
Single, ByVal Y As Single)
Dim MyDataObject As DataObject
If Button = 1 Then
Set MyDataObject = New DataObject
Dim Effect As Integer
MyDataObject.SetText ListBox1.Value
Effect = MyDataObject.StartDrag
End If
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Frédéric Sigonneau
Bonsoir,
Si avec ton code actuel tu ajoutes bien un élément dans la 1ère colonne de la ListBox, essaye ce genre de syntaxe pour la deuxième colonne (non testé) :
ListBox2.AddItem Data.GetText 'ajoute un élément en colonne 1 dernière ligne ListBox2.List(ListBox2.ListCount,1)="le 2ème élément"
FS -- Frédéric Sigonneau [MVP Excel - né un sans-culottide] Gestions de temps, VBA pour Excel : http://perso.wanadoo.fr/frederic.sigonneau Si votre question sur Excel est urgente, évitez ma bal !
Comment peut on faire pour deplacer un objet d'une liste box a 2 colonne vers une autre ? ex : listbox1 listbox2 essai1 choix1 essai2 choix2 essai3 choix3
j'aimerai par drag n drop avoir listbox1 listbox2 essai1 choix1 essai2 choix2 essai3 choix3
voici le code que j'utilise mais je ne sais pas qu'elle mofdif il faut faire pour qu'il prenne en compte les deux colonnes. merci d'avance
Private Sub ListBox2_BeforeDragOver(ByVal Cancel As _ MSForms.ReturnBoolean, ByVal Data As _ MSForms.DataObject, ByVal X As Single, _ ByVal Y As Single, ByVal DragState As Long, _ ByVal Effect As MSForms.ReturnEffect, _ ByVal Shift As Integer)
Cancel = True Effect = 1 End Sub
Private Sub ListBox2_BeforeDropOrPaste(ByVal _ Cancel As MSForms.ReturnBoolean, _ ByVal Action As Long, ByVal Data As _ MSForms.DataObject, ByVal X As Single, _ ByVal Y As Single, ByVal Effect As _ MSForms.ReturnEffect, ByVal Shift As Integer) Cancel = True Effect = 1 ListBox2.AddItem Data.GetText End Sub
Private Sub ListBox1_MouseMove(ByVal Button As _ Integer, ByVal Shift As Integer, ByVal X As _ Single, ByVal Y As Single) Dim MyDataObject As DataObject
If Button = 1 Then Set MyDataObject = New DataObject Dim Effect As Integer MyDataObject.SetText ListBox1.Value Effect = MyDataObject.StartDrag End If
End Sub
Bonsoir,
Si avec ton code actuel tu ajoutes bien un élément dans la 1ère colonne de la
ListBox, essaye ce genre de syntaxe pour la deuxième colonne (non testé) :
ListBox2.AddItem Data.GetText 'ajoute un élément en colonne 1 dernière ligne
ListBox2.List(ListBox2.ListCount,1)="le 2ème élément"
FS
--
Frédéric Sigonneau [MVP Excel - né un sans-culottide]
Gestions de temps, VBA pour Excel :
http://perso.wanadoo.fr/frederic.sigonneau
Si votre question sur Excel est urgente, évitez ma bal !
Comment peut on faire pour deplacer un objet d'une liste
box a 2 colonne vers une autre ?
ex :
listbox1 listbox2
essai1 choix1
essai2 choix2
essai3 choix3
j'aimerai par drag n drop avoir
listbox1 listbox2
essai1 choix1 essai2 choix2
essai3 choix3
voici le code que j'utilise mais je ne sais pas qu'elle
mofdif il faut faire pour qu'il prenne en compte les deux
colonnes.
merci d'avance
Private Sub ListBox2_BeforeDragOver(ByVal Cancel As _
MSForms.ReturnBoolean, ByVal Data As _
MSForms.DataObject, ByVal X As Single, _
ByVal Y As Single, ByVal DragState As Long, _
ByVal Effect As MSForms.ReturnEffect, _
ByVal Shift As Integer)
Cancel = True
Effect = 1
End Sub
Private Sub ListBox2_BeforeDropOrPaste(ByVal _
Cancel As MSForms.ReturnBoolean, _
ByVal Action As Long, ByVal Data As _
MSForms.DataObject, ByVal X As Single, _
ByVal Y As Single, ByVal Effect As _
MSForms.ReturnEffect, ByVal Shift As Integer)
Cancel = True
Effect = 1
ListBox2.AddItem Data.GetText
End Sub
Private Sub ListBox1_MouseMove(ByVal Button As _
Integer, ByVal Shift As Integer, ByVal X As _
Single, ByVal Y As Single)
Dim MyDataObject As DataObject
If Button = 1 Then
Set MyDataObject = New DataObject
Dim Effect As Integer
MyDataObject.SetText ListBox1.Value
Effect = MyDataObject.StartDrag
End If
Si avec ton code actuel tu ajoutes bien un élément dans la 1ère colonne de la ListBox, essaye ce genre de syntaxe pour la deuxième colonne (non testé) :
ListBox2.AddItem Data.GetText 'ajoute un élément en colonne 1 dernière ligne ListBox2.List(ListBox2.ListCount,1)="le 2ème élément"
FS -- Frédéric Sigonneau [MVP Excel - né un sans-culottide] Gestions de temps, VBA pour Excel : http://perso.wanadoo.fr/frederic.sigonneau Si votre question sur Excel est urgente, évitez ma bal !
Comment peut on faire pour deplacer un objet d'une liste box a 2 colonne vers une autre ? ex : listbox1 listbox2 essai1 choix1 essai2 choix2 essai3 choix3
j'aimerai par drag n drop avoir listbox1 listbox2 essai1 choix1 essai2 choix2 essai3 choix3
voici le code que j'utilise mais je ne sais pas qu'elle mofdif il faut faire pour qu'il prenne en compte les deux colonnes. merci d'avance
Private Sub ListBox2_BeforeDragOver(ByVal Cancel As _ MSForms.ReturnBoolean, ByVal Data As _ MSForms.DataObject, ByVal X As Single, _ ByVal Y As Single, ByVal DragState As Long, _ ByVal Effect As MSForms.ReturnEffect, _ ByVal Shift As Integer)
Cancel = True Effect = 1 End Sub
Private Sub ListBox2_BeforeDropOrPaste(ByVal _ Cancel As MSForms.ReturnBoolean, _ ByVal Action As Long, ByVal Data As _ MSForms.DataObject, ByVal X As Single, _ ByVal Y As Single, ByVal Effect As _ MSForms.ReturnEffect, ByVal Shift As Integer) Cancel = True Effect = 1 ListBox2.AddItem Data.GetText End Sub
Private Sub ListBox1_MouseMove(ByVal Button As _ Integer, ByVal Shift As Integer, ByVal X As _ Single, ByVal Y As Single) Dim MyDataObject As DataObject
If Button = 1 Then Set MyDataObject = New DataObject Dim Effect As Integer MyDataObject.SetText ListBox1.Value Effect = MyDataObject.StartDrag End If