Results 1 to 1 of 1

Thread: Drag and Drop, copy file(s) to clipboard?

  1. #1

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Unhappy Drag and Drop, copy file(s) to clipboard?

    I want to drag and drop files into my richtextbox.
    The result i want is this. (I did this by selecting the image in explorer, copy it and then paste it in rtb) <--- I want this to happen on drag drop
    Name:  forum.jpg
Views: 425
Size:  14.2 KB

    I did however get images to automatically copy and paste into the rtb when I drag and drop it in, but this pastes the image and not the image file like in my example. Now I just need files to copy and paste into the rtb like in the image.

    Please give me some code to do this.

    Oh, this is the code i used for the image.
    vb.net Code:
    1. Private Sub rtb_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles rtb.DragDrop
    2.         Dim img As Image
    3.         img = Image.FromFile(CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString)
    4.         Clipboard.SetImage(img)
    5.         Me.Text = e.Data.ToString
    6.         rtb.SelectionStart = 0
    7.         rtb.Paste()
    8.     End Sub
    9.  
    10.     Private Sub rtb_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles rtb.DragEnter
    11.         If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
    12.             e.Effect = DragDropEffects.Copy
    13.         End If
    14.     End Sub
    Last edited by tgf-47; Apr 6th, 2011 at 08:15 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width