-
Apr 6th, 2011, 08:04 AM
#1
Thread Starter
Addicted Member
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
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:
Private Sub rtb_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles rtb.DragDrop
Dim img As Image
img = Image.FromFile(CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString)
Clipboard.SetImage(img)
Me.Text = e.Data.ToString
rtb.SelectionStart = 0
rtb.Paste()
End Sub
Private Sub rtb_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles rtb.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.Copy
End If
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|