Question

I'm trying to make like a container application where you can drag and drop files of any kind on the form and afterwards to be able to open it from there. I found some solutions where you can drag and drop files to a list view and you get it's path.. but is not how I want.. I want to have on my form in a panel or what ever is better like a shortcut of the file, an image or something to be able to see the file icon like is in explorer.

Have someone ever done something like this or point me to the right direction?

Was it helpful?

Solution

Set "Allow drop" property to "true" on your control and make use of Control.DragDrop event - it's exist on all controls, and it's invoked after drag'n'drop anything on anything(if "Allow drop" is true of course).

It this event-handler you can add new item to this or another control(ListView fits nicely to your needs), and for example to some "Dictionary" where you will store "Item and filename mapping".

Also you need to make handler for item click'ing - for ListView there a ItemActivate event. Inside this handler you can click execute default shell-action for this file by using Process.Start

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top