Results 1 to 10 of 10

Thread: Drag Drop files from windows into VB.NET

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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 08:27 AM.

  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
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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?

  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,885

    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
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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

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

    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
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  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
  •  



Click Here to Expand Forum to Full Width