Drag & Drop sur une Form

Résolu
allthew3 Messages postés 551 Date d'inscription samedi 8 janvier 2005 Statut Membre Dernière intervention 12 avril 2008 - 27 juin 2007 à 13:03
allthew3 Messages postés 551 Date d'inscription samedi 8 janvier 2005 Statut Membre Dernière intervention 12 avril 2008 - 27 juin 2007 à 13:15
Bonjour,

J'ai une form avec un TabControl qui utilise tout l'espace : je voudrais pouvoir glisser un fichier sur la fenetre (pour obtenir le chemin d'accès à ce fichier et effectué des actions dessus)

J'ai bien mis AllowDrop = true mais je n'y arrive pas : voilà mes evenements :

Private

Sub Principal_DragEnter(
ByVal sender
As System.Object,
ByVal e
As System.Windows.Forms.DragEventArgs)
Handles
Me.DragEnter, TabControl.DragEnter, TabAntivirus.DragEnter

If e.Data.GetDataPresent(DataFormats.FileDrop)
Thene.Effect = DragDropEffects.Copy

Elsee.Effect = DragDropEffects.None

End
If

End
Sub

Private
Sub Principal_DragDrop(
ByVal sender
As System.Object,
ByVal e
As System.Windows.Forms.DragEventArgs)
Handles
Me.DragDrop, TabControl.DragDrop, TabAntivirus.DragDrop

Dim strFiles
As
String = e.Data.GetData(DataFormats.FileDrop).ToString
' action sur strFiles

End
If

End
Sub

2 réponses

allthew3 Messages postés 551 Date d'inscription samedi 8 janvier 2005 Statut Membre Dernière intervention 12 avril 2008 2
27 juin 2007 à 13:15
post inutile (désolé admin et modo) : je viens de trouver la solution
3
allthew3 Messages postés 551 Date d'inscription samedi 8 janvier 2005 Statut Membre Dernière intervention 12 avril 2008 2
27 juin 2007 à 13:07
après modification, voici mon code :

Private

Sub Principal_DragEnter(
ByVal sender
As System.Object,
ByVal e
As System.Windows.Forms.DragEventArgs)
Handles
Me.DragEnter, TabControl.DragEnter, TabAntivirus.DragEnter

If e.Data.GetDataPresent(DataFormats.FileDrop)
Thene.Effect = DragDropEffects.Copy

Elsee.Effect = DragDropEffects.None

End
If

Dim strFiles
As
String = e.Data.GetData(DataFormats.FileDrop,
True).ToString

' action sur le fichier

End
Sub
1
Rejoignez-nous