Drag n Drop Issue
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts
Page 1 of 1
Hey Coders
I have a problem with Drag n Drop Images to a RichTextBox
I am using VB 2010 Pro
It works fine when i am creating the app and run it within VB, But when I build it and run it on the desktop the Drag n Drop does not work..
This is the code below I am using for Drag n Drop
Imports
Form Load
Cheers
Chris
I have a problem with Drag n Drop Images to a RichTextBox
I am using VB 2010 Pro
It works fine when i am creating the app and run it within VB, But when I build it and run it on the desktop the Drag n Drop does not work..
This is the code below I am using for Drag n Drop
Imports
Code: Select all
Imports System.Reflection
Imports System.IO
Form Load
Code: Select all
RichTextBox1.AllowDrop = True
Code: Select all
Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
Dim files As Array = e.Data.GetData(DataFormats.FileDrop)
MsgBox(files.Length & " Image Added")
Dim bmpFormat As DataFormats.Format = DataFormats.GetFormat(DataFormats.Bitmap)
For i As Integer = 0 To files.Length - 1
Dim bmp As Bitmap = Bitmap.FromFile(files(i))
Clipboard.SetData(DataFormats.Bitmap, bmp)
bmp.Dispose()
RichTextBox1.Paste(bmpFormat)
Next
Clipboard.Clear()
End Sub
Code: Select all
Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Cheers
Chris
Your code looks fine and it works for me.
Make sure you run the application as administrator and see if that works.
Make sure you run the application as administrator and see if that works.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Hey Cody
I am running it as admin, I tried it in VB 2013 Community Edition and that throws up errors for .Net Framework. But I am sure I have the .Net frameworks installed, so I dont know what the issue is?
Chris
I am running it as admin, I tried it in VB 2013 Community Edition and that throws up errors for .Net Framework. But I am sure I have the .Net frameworks installed, so I dont know what the issue is?
Chris
Check if you have any system/windows updates that need downloading and installing.
I'm not sure what could be wrong :?
Try this one that I made using your code, I've tested it and it works fine for me.
I'm not sure what could be wrong :?
Try this one that I made using your code, I've tested it and it works fine for me.
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023