ドラッグ&ドロップする

example (VB.net)

Private Sub PreviewDragEvent _
  (ByVal sender As System.Object, _
   ByVal e As System.Windows.DragEventArgs) _
   Handles TextBox1.PreviewDragEnter, TextBox1.PreviewDragOver
 
  e.Effects = DragDropEffects.Copy
  e.Handled = True
 
End Sub
 
Private Sub PreviewDropEvent _
  (ByVal sender As System.Object, _
   ByVal e As System.Windows.DragEventArgs)_
   Handles TextBox1.PreviewDrop
 
  Dim Files As String() = e.Data.GetData(DataFormats.FileDrop, False)
  If Files.Length = 1 Then
    Dim target As TextBox = CType(sender, TextBox)
    target.Text = Files(0)
  End If
 
End Sub