title: Drag and drop files into program
body: <p>I'm using MonoDevelop tool. <br>
  I want to make program like below with GTK#; <br> 
  <br>
  1. User drags file to program's listView, tableView or whatever <br>
  2. Dragged file's list is printed on the program's window <br>
  <br></p>
  
  <p>But I'm almost new to GTK# and find the way how to drag and drop, <br>
  so I searched information about it and found this link like below. <br>
  <a href="http://developer.gnome.org/gtkmm-tutorial/3.0/sec-dnd-example.html.en" rel="nofollow">http://developer.gnome.org/gtkmm-tutorial/3.0/sec-dnd-example.html.en</a> <br>
  <br>
  This is the code I tried to make program link suggested <br>
  (This link explains drag and drop in C++ and I had to make it the way like C#) <br><br>
      using Gtk;
      using System;
      using System.Collections;
      using System.Collections.Generic;</p>
  
  <pre><code>namespace DragAndDrop
  {
      public class SharpApp: Window
      {
          Button btnDrag;
          Label lblDrop;
          HBox hbox;
  
          public SharpApp (): base("Title")
          {
              btnDrag = new Button("Drag Here");
              lblDrop = new Label("Drop Here");
              hbox = new HBox();
  
              SetDefaultSize(250,200);
              SetPosition (Gtk.WindowPosition.Center);
              DeleteEvent += (o, args) =&gt; Application.Quit ();
  
              // Targets
              List&lt;TargetEntry&gt; list
                  = new List&lt;TargetEntry&gt; ();
              list.Add (new TargetEntry
                        ("STRING", TargetFlags.Widget, 0));
              list.Add (new TargetEntry
                        ("text/plain", TargetFlags.Widget, 0));
  
              // Drag site -----
              // Make btnDrag a DnD drag source:
              TargetEntry[] entries = list.ToArray();
              TargetEntry[] se = new TargetEntry[] {entries[0]};
  
              Drag.SourceSet (btnDrag, Gdk.ModifierType.ModifierMask,
                              se, Gdk.DragAction.Copy);
  
              // Connect signals
              btnDrag.DragDataGet += delegate
                  (object o, DragDataGetArgs args) {
                  Console.WriteLine ("Test");
                  OnDragDataGet(args.Context,
                                args.SelectionData,
                                args.Info,
                                args.Time);
              };
  
              hbox.PackStart (btnDrag);
  
              // Drop site -----
              // Make lblDrop a DnD drop destination:
              TargetEntry[] de = new TargetEntry[] {entries[1]};
  
              Drag.DestSet (lblDrop, DestDefaults.Drop,
                            de, Gdk.DragAction.Copy);
  
  
              // Connect signals
              lblDrop.DragDataReceived += delegate
                  (object o, DragDataReceivedArgs args) {
                  Console.WriteLine ("Test");
                  OnDragDataReceived(args.Context,
                                     args.X,
                                     args.Y,
                                     args.SelectionData,
                                     args.Info,
                                     args.Time);
              };
  
              // hbox
              hbox.PackStart (lblDrop);
  
              Add (hbox);
  
              ShowAll ();
          }
  
          // event handlers
          protected override void OnDragDataGet
              (Gdk.DragContext context, SelectionData sdata,
               uint info, uint time)
          {
              Console.WriteLine ("OnDragDataGet");
  
              string tmp = "I'm data!";
              byte[] b = new byte[tmp.Length];
              for (int i=0; i&lt;tmp.Length; ++i)
                  b[i] = (byte)tmp[i];
  
              sdata.Set(sdata.Target, 8, b, tmp.Length);
          }
          protected override void OnDragDataReceived
              (Gdk.DragContext context, int x, int y,
               SelectionData sdata, uint info, uint time)
          {
              Console.WriteLine ("OnDragDataReceived");
  
              int length = sdata.Length;
              if ((length&gt;=0) &amp;&amp; (sdata.Format==8))
              {
                  Console.WriteLine ("Received \"{0}\" in label",
                                     sdata.Data.ToString());
              }
  
              Drag.Finish (context, false, false, time);
          }
  
          // main
          public static void Main (string[] args)
          {
              Application.Init ();
              new SharpApp();
              Application.Run ();
          }
      }
  }
  </code></pre>
  
  <p>but the result tells me I might be wrong.. I thought the button will be moved <br>
  when I drag it, but the button didn't move at all. Is there anyone able to fix my problem?</p>