Bonjour
Pouvez-vous me dépanner le code source qui ne fonctionne pas.
Le drop file ne fonctionne pas du tout !!! sur le listbox .

J'appelle une modal d'une dll c# depuis le code non manager ! et ca ne marche pas, aucun evenement Ondrop onenter .... n'est appeller !

Merci.

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
 public partial class ftestfile : Form
    {
 
        internal const string nameC = "listm";
        public ftestfile()
        {
            InitializeComponent();
 
 
 
        }
 
 
        private void mdp_button__lingue_15_Click(object sender, EventArgs e)
        {
 
            Close();
        }
 
        private void ftestfile_Load(object sender, EventArgs e)
        {
           mdp_lstbox_out.AllowDrop = true;
        }
 
        private void ftestfile_MouseMove(object sender, MouseEventArgs e)
        {
            int x = e.X; //ca passe dedans
        }
 
        private void edrop(object sender, DragEventArgs e) //n'est pas appeller du tout !
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            int nb = 1;
            foreach (string file in files)
            {
                mdp_lstbox_out.Items.Add(file);
            }
        }
 
        private void eenter(object sender, DragEventArgs e) //n'est pas appeller du tout !
        {
            e.Effect = DragDropEffects.Copy;
 
        }
    }
Designer :
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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
namespace Test3
{
    partial class ftestfile
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
 
        #region Windows Form Designer generated code
 
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.mdp_lstbox_out = new System.Windows.Forms.ListBox();
            this.mdp_button__lingue_16 = new System.Windows.Forms.Button();
            this.mdp_button__lingue_15 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // mdp_lstbox_out
            // 
            this.mdp_lstbox_out.AllowDrop = true;
            this.mdp_lstbox_out.FormattingEnabled = true;
            this.mdp_lstbox_out.Location = new System.Drawing.Point(38, 31);
            this.mdp_lstbox_out.Name = "mdp_lstbox_out";
            this.mdp_lstbox_out.Size = new System.Drawing.Size(220, 225);
            this.mdp_lstbox_out.TabIndex = 0;
            this.mdp_lstbox_out.DragDrop += new System.Windows.Forms.DragEventHandler(this.edrop);
            this.mdp_lstbox_out.DragEnter += new System.Windows.Forms.DragEventHandler(this.eenter);
            // 
            // mdp_button__lingue_16
            // 
            this.mdp_button__lingue_16.Location = new System.Drawing.Point(107, 399);
            this.mdp_button__lingue_16.Name = "mdp_button__lingue_16";
            this.mdp_button__lingue_16.Size = new System.Drawing.Size(78, 23);
            this.mdp_button__lingue_16.TabIndex = 12;
            this.mdp_button__lingue_16.Text = "button2";
            this.mdp_button__lingue_16.UseVisualStyleBackColor = true;
            // 
            // mdp_button__lingue_15
            // 
            this.mdp_button__lingue_15.Location = new System.Drawing.Point(107, 369);
            this.mdp_button__lingue_15.Name = "mdp_button__lingue_15";
            this.mdp_button__lingue_15.Size = new System.Drawing.Size(78, 24);
            this.mdp_button__lingue_15.TabIndex = 11;
            this.mdp_button__lingue_15.Text = "button2";
            this.mdp_button__lingue_15.UseVisualStyleBackColor = true;
            this.mdp_button__lingue_15.Click += new System.EventHandler(this.mdp_button__lingue_15_Click);
            // 
            // ftestfile
            // 
            this.AllowDrop = true;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(346, 450);
            this.Controls.Add(this.mdp_button__lingue_16);
            this.Controls.Add(this.mdp_button__lingue_15);
            this.Controls.Add(this.mdp_lstbox_out);
            this.Name = "ftestfile";
            this.Text = "ftestfile";
            this.Load += new System.EventHandler(this.ftestfile_Load);
            this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ftestfile_MouseMove);
            this.ResumeLayout(false);
 
        }
 
        #endregion
 
        private System.Windows.Forms.ListBox mdp_lstbox_out;
        private System.Windows.Forms.Button mdp_button__lingue_16;
        private System.Windows.Forms.Button mdp_button__lingue_15;
    }
}
Les méthodes eenter et edrag ne sont pas appeller du tout !

J'appelle depuis le code non manager un dll c# qui contient un winformet le drop file ne fonctionne pas !

J'ai essayer sur un nouveau projet winform c# ,ca marche ! je ne comprend pas !

Existe t'il des utilitaires de diagnostiques pour ce genre de probléme ?

J'ai essayer d'executer ShowDialog sur un autre thread , ça fonctionne mais dans le thread principale.

Merci


merci de me dépanner !