Drag and drop

TeXmeX34 Messages postés 1 Date d'inscription mercredi 12 avril 2006 Statut Membre Dernière intervention 12 avril 2006 - 12 avril 2006 à 16:54
OneHacker Messages postés 1447 Date d'inscription jeudi 2 novembre 2000 Statut Membre Dernière intervention 23 septembre 2007 - 12 avril 2006 à 19:04
Bonjour,
je cherche à activer la gestion du drag and drop sous .net. En effet, depuis que la propriété DragMode n'est plus disponible pour les objets de type PictureBox, je ne sais comment faire. Sous VB 6.0 il suffisait d'activer cette option sur Automatic, et ensuite de rajouter les ligne de code suivante :

Private Sub joue_Drag_Drop(Index As Integer, Source As Control, X As Single, Y As Single)
joue(Index) = couleur(Source.Index)
End sub

Je cherche à faire pareil sous .net ! Et bien évidemment cette procédure n'est plus compatible.
Il s'agit deplacer et déposer une image sur un autre objet aussi de type PictureBox.

D'avance, merci.

1 réponse

OneHacker Messages postés 1447 Date d'inscription jeudi 2 novembre 2000 Statut Membre Dernière intervention 23 septembre 2007 2
12 avril 2006 à 19:04
Le problème c'est que je connais la fonction, elle ne me fait pas d'erreur mais ne marche pas j'ai utilisé l'aide de VS 2003 .NET pour ça alors regarde ce code :


Private
Sub PictureBox1_MouseDown(
ByVal sender
As
Object,
ByVal e
As System.Windows.Forms.MouseEventArgs)
Handles PictureBox1.MouseDown


PictureBox1.DoDragDrop(PictureBox1.Image, DragDropEffects.Copy
Or DragDropEffects.Move)



End
Sub



Private
Sub PictureBox2_MouseDown(
ByVal sender
As
Object,
ByVal e
As System.Windows.Forms.MouseEventArgs)
Handles PictureBox2.MouseDown


PictureBox2.DoDragDrop(PictureBox2.Image, DragDropEffects.Copy
Or DragDropEffects.Move)



End
Sub



Private
Sub PictureBox1_DragEnter(
ByVal sender
As
Object,
ByVal e
As System.Windows.Forms.DragEventArgs)
Handles PictureBox1.DragEnter



If (e.Data.GetDataPresent(DataFormats.Bitmap))
Then


e.Effect = DragDropEffects.Copy



Else


e.Effect = DragDropEffects.None



End
If



End
Sub



Private
Sub PictureBox2_DragEnter(
ByVal sender
As
Object,
ByVal e
As System.Windows.Forms.DragEventArgs)
Handles PictureBox2.DragEnter



If (e.Data.GetDataPresent(DataFormats.Bitmap))
Then


e.Effect = DragDropEffects.Copy



Else


e.Effect = DragDropEffects.None



End
If



End
Sub



Private
Sub PictureBox1_DragDrop(
ByVal sender
As
Object,
ByVal e
As System.Windows.Forms.DragEventArgs)
Handles PictureBox1.DragDrop


PictureBox1.Image = e.Data.GetData(DataFormats.Bitmap)



End
Sub



Private
Sub PictureBox2_DragDrop(
ByVal sender
As
Object,
ByVal e
As System.Windows.Forms.DragEventArgs)
Handles PictureBox2.DragDrop


PictureBox2.Image = e.Data.GetData(DataFormats.Bitmap)



End
Sub

Le code est bon mais ca marche pas quand même !! C'est chiant !

Redman
0
Rejoignez-nous