1 Attachment(s)
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
Attachment 83409
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