Question Drag and drop to retrieve file names?

davidfes88

New member
Joined
Feb 14, 2012
Messages
2
Programming Experience
Beginner
Hi guys,

I am a beginner, but I've managed to make a program. I need help with the following if possible...

My question is, how can I implement a drag and drop of images into my program? I only need the file names of these images. So basically, user can select a few images, and drag into my program, and then I want the file names of those images to be displayed onto different text boxes.

So image 1 file name onto text box 1
Image 2 file name onto text box 2
etc...

Thanks!
Dave
 
In that article read at least the "How Drag and Drop Works" and "Dragging Files" sections.
Hmmm. I can't really understand it
Hmmm. Try again. You can't find a simpler filedrop sample than that, and the article explains things in simple terms also.
 
@davidfes88
Also this might be useful for you too.

VBForums - View Single Post - Drag Drop files from windows into VB.NET

===================================================================================================================

@JohnH
btw I have a question I'd like to ask for help from JohnH. Don't mind the fact that I didn't start a new thread because its regarding the original question. I'd be grateful if you could help me out.

This question got me interested since I haven't worked with drag and drop operations before so I tried it out. This is the UI.

2-15-2012 11-22-36 PM.png

I got it working except I have a small problem. If I drag and drop from an image straight from anywhere, it works. But that Select Image button invokes a OpenFileDialog. It doesn't work that way if I click that and browse a folder and drag an image through that. I suppose that's how OpenFileDialog works. Only opens a file. I just wanna know is there any way to overcome this issue. A different control perhaps? FolderBrowserDialog doesn't help since it only look for folders. Any other way?

Thanks a lot. :)
 
I suppose that's how OpenFileDialog works. Only opens a file.
OpenFileDialog is a dialog that lets user select a file. What you do with the selection is up to you, the dialog expose the FileName property that has the path of the selected file (which is the same data you get out of a filedrop).
 
OpenFileDialog is a dialog that lets user select a file. What you do with the selection is up to you, the dialog expose the FileName property that has the path of the selected file (which is the same data you get out of a filedrop).

no, the problem is not with the data. I just cannot drag files from a OpenFileDialog.

drag.png

Is there any other way around this?
 
No, you can drag files from Window Explorer to your application. In a OpenFileDialog user can select files and click Ok button (or just doubleclick the file).
 
Back
Top