IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Forms Discussion :

drag & drop treeview=>listbox


Sujet :

Windows Forms

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 22
    Points : 18
    Points
    18
    Par défaut drag & drop treeview=>listbox
    Bonjour a tous,
    je cherche a faire un drag&drop treeview vers une listbox...
    J'ai essayé plusieurs fois avec ce que j'ai trouvé sur le net mais sans succes(le drop marche pas )
    qqun l'aurait il deja fait?
    merci

  2. #2
    AP
    AP est déconnecté
    Membre confirmé
    Avatar de AP
    Profil pro
    Inscrit en
    Avril 2002
    Messages
    480
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2002
    Messages : 480
    Points : 538
    Points
    538
    Par défaut
    as-tu positionné le allowdrop de ton control destination à true?
    Quel est le code de tes fonctions DragEnter, DragOver et DragDrop de ton control destination?

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 22
    Points : 18
    Points
    18
    Par défaut
    Oui j'ai positionné les flags allowDrop a true
    Je n'ai pas de drag over... est ce necessaire?

    Voici le code source:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
           private void Form1_Load(object sender, EventArgs e)
            {
                this.treeView1.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView_ItemDrag);
                this.treeView1.DragEnter += new System.Windows.Forms.DragEventHandler(this.my_DragEnter);
                this.listBox1.DragEnter += new System.Windows.Forms.DragEventHandler(this.my_DragEnter);
                this.listBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.listBox_DragDrop);	
            }
    
            private void treeView_ItemDrag(object sender,
                        System.Windows.Forms.ItemDragEventArgs e)
            {
                DoDragDrop(e.Item, DragDropEffects.Move);
            }
    
            private void my_DragEnter(object sender,
                        System.Windows.Forms.DragEventArgs e)
            {
                e.Effect = DragDropEffects.Move;
            }
    
            private void listBox_DragDrop(object sender,
                        System.Windows.Forms.DragEventArgs e)
            {
                      listBox1.Items.Add(e.Data.GetData(DataFormats.Text));
            }

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    547
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 547
    Points : 627
    Points
    627
    Par défaut
    Salut,

    c'est le callback de TextBoxDragDrop qui coince. Tu dois typer l'objet du IDataObject pour le recuperer, ici en entrée tu lui donne un TreeNode (DoDragDrop(e.Item, DragDropEffects.Move)) et en sortie tu veux un text, ca ne marche pas. =)

    Essaie plutot :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    private void listBox_DragDrop(object sender,
    System.Windows.Forms.DragEventArgs e)
    {
    listBox1.Items.Add(e.Data.GetData(typeof(TreeNode)));
    }

  5. #5
    Futur Membre du Club
    Inscrit en
    Juin 2008
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Juin 2008
    Messages : 6
    Points : 6
    Points
    6
    Par défaut
    Puisque ca n'a pas été fait, je te dis MERCI !!!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [VBA-E]drag and drop entre deux listbox
    Par Yolak dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 14/06/2012, 14h37
  2. Drag and drop entre deux ListBox
    Par simoinfonet dans le forum Langage
    Réponses: 0
    Dernier message: 18/04/2008, 18h53
  3. Drag and drop treeview
    Par exile69 dans le forum C#
    Réponses: 3
    Dernier message: 21/02/2008, 10h14
  4. Drag and drop sur une listbox (access 2002)
    Par puballenou dans le forum IHM
    Réponses: 1
    Dernier message: 23/11/2006, 17h57
  5. drag and drop sur une listBox?
    Par Mickey.jet dans le forum Delphi
    Réponses: 3
    Dernier message: 30/09/2006, 10h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo