Drag Drop files from windows into VB.NET-VBForums
Results 1 to 10 of 10

Thread: Drag Drop files from windows into VB.NET

Hybrid View

  1. #1

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,284

    Drag Drop files from windows into VB.NET

    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.
    Attached Files Attached Files
    Last edited by kleinma; Apr 26th, 2006 at 09:27 AM.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  2. #2
    New Member
    Join Date
    Aug 2006
    Posts
    3

    Re: Drag Drop files from windows into VB.NET

    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

  3. #3

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,284

    Re: Drag Drop files from windows into VB.NET

    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?
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  4. #4
    New Member
    Join Date
    Aug 2006
    Posts
    3

    Re: Drag Drop files from windows into VB.NET

    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

  5. #5
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,838

    Re: Drag Drop files from windows into VB.NET

    Quote Originally Posted by 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.
    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?

  6. #6

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,284

    Re: Drag Drop files from windows into VB.NET

    Quote Originally Posted by BrailleSchool
    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
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  7. #7
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,838

    Re: Drag Drop files from windows into VB.NET

    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.

  8. #8

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,284

    Re: Drag Drop files from windows into VB.NET

    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.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  9. #9
    New Member
    Join Date
    Jan 2010
    Posts
    1

    Re: Drag Drop files from windows into VB.NET

    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
    Last edited by morokat; Jan 30th, 2010 at 09:19 AM.

  10. #10
    New Member piboss's Avatar
    Join Date
    Apr 2011
    Location
    Cleveland, Ohio, USA
    Posts
    5

    Thumbs up Re: Drag Drop files from windows into VB.NET

    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

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.