# VBForums CodeBank > CodeBank - Visual Basic .NET >  Drag Drop files from windows into VB.NET

## kleinma

this example allows you to drag an image file from outside your app onto a picturebox, and VB will handle it via drag/drop to display the image.

this is just a sample, but could easily be modified for using other file types. I couldn't find much on the web for doing this type of stuff... so I thought it might be useful to others.

----------


## rtend

Hello to all members,

I've a problem with darg&drop using VB.NET 2003. I want to drop files from explorer, running under user x, to my application, running under user y.
With the code for "normal" drag&drop it doesn't works.
Any solutions?

Thank you for help
Reinhard

----------


## kleinma

Your question would really be better in the VB.NET forum here, as this is really just the codebank forum, where example code is posted. Not too many people are in this specific forum actually answering questions.

I don't have an answer for you, but I am sure it has to do with permissions. Do you get an error of any sort? Is User Y a higher level user than User X? Like your app is running under admin permissions, but the logged in user only has user permissions?

----------


## rtend

Sorry for posting in codebank forum. Could you transfer posting to the vb.net forum?

I don't get any error. Running my application and the explorer with users with the same level will not solve my problem.

I tested some things. I can display a massagebox, when I enter the form of my application, mouseenter handle. The dragenter handle isn't fired.

Any ideas?

Thank you for help,
Reinhard

----------


## BrailleSchool

> this example allows you to drag an image file from outside your app onto a picturebox, and VB will handle it via drag/drop to display the image.
> 
> this is just a sample, but could easily be modified for using other file types. I couldn't find much on the web for doing this type of stuff... so I thought it might be useful to others.


thanks for the example kleinma.  when it comes to the picturebox, i am unable to set it to allowdrop = true in form load because it doesnt show as an option in 2005 express?  but when i type it in anyway, it allows it.  why is that?

----------


## kleinma

> thanks for the example kleinma.  when it comes to the picturebox, i am unable to set it to allowdrop = true in form load because it doesnt show as an option in 2005 express?  but when i type it in anyway, it allows it.  why is that?



Great question. I had the same one myself and emailed Microsoft to find out.

I wrote




> Microsoft:
> 
>     With reference to the .NET picturebox control, why does the .AllowDrop property have to be set at runtime in code rather than being set at design time in the picturebox properties? All other controls that have this property allow you to set at design time. Is there a reason why the picturebox is different?


I got this response:



> Thank you for contacting the .NET Framework team. We appreciate your comments. By taking the time to write, you are helping us to improve the quality of our documentation and samples.
> 
> The PictureBox control is not designed to allow drag and drop procedures. However, since PictureBox inherits from control, it also inherits the AllowDrop property. To clarify this, in the next release of the documentation, the PictureBox.AllowDrop topic will be marked with the for internal use only boilerplate. Also, the PictureBox.AllowDrop property will not appear in intellisense if you are using the Visual Studio text editor.


to which I replied:



> Thank you for your response. Is there any specific reason why the picturebox is not "designed" to allow drag/drop procedures? Is there any negative impact to using a picture box for such tasks? For example, a picturebox you can drag image files from windows explorer over and have it display the image in the box on drop. It just seems odd to me why something with inherited functionality to be limited. I imagine the Microsoft developers have some reasoning behind this, correct?


To which I never got any response  :Cry:

----------


## BrailleSchool

sure doesnt make sense because thats what i thought a picture box was all about.  to be able to handle pictures/images in many different ways.  least you got a reply from your initial request.  microsoft is kinda strange at the best of times anyway.

----------


## kleinma

when I find errors in the documentation, or I find behavior in a class/control that doesn't mirror what the documentation says, I always email the doc team there at MS. I don't think there has been one time I haven't gotten an initial response back with an answer.

----------


## morokat

thanks u for ur code drag and drop....

sir can u tell me agian ?on how to drag and drop from vb.net to explorer(desktop)or device?
like i'm has program for control music joint with access database so if i want drag to desktop can or not?
ples see picture
thanks u

----------


## piboss

Thanks!  I'm not sure why I didn't figure that out but regardless, your example is simple, concise and to the point.  I really appreciate your post!

Glenn

----------

