❔ Drag and drop not working
It appears with a prohibited sign
Here's my code:
namespace WinFormsAppPrueba
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
}
}
}
8 Replies
i think your logic is backwards
you should set your curso/ effect onenter
and you should get the data on drop
i think you have to enable dropping as well
Control.AllowDrop Property (System.Windows.Forms)
Gets or sets a value indicating whether the control can accept data that the user drags onto it.
Oh yeah now it works
@Anchy
Even though that code is a mockup, for the real app i need admin privilage and there is failing
start the app as admin then
if you want the app to request admin then look into application manifests
namely
requestedPrivileges
and requestedExecutionLevel
yeah, i mean when i run the app as admin drag and drop is not allowed, @Anchy
Stack Overflow
Drag and drop event can not be fired when running visual studio in ...
I use Visual Studio 2008, .net framework 3.5
I have an webservice application (a winform client which is using webservice), and I have to run it in Administrator account
I need to drag and drop f...
could be relevant here
it's due to the UAC so I'm not sure how you can get around it
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.