C# Drag Drop Does Not Work on Windows 7

C# Drag drop does not work on windows 7

The source and target processes need to have compatible security levels/privileges. For example, if your source is Explorer and it is running with user level privileges, but your target application is running with administrator (elevated) level permission, you will not be able to drag&drop as this is seen as a security issue as the target is running with a higher level of privileges.

How to get Drag and Drop to work on Windows 7

You must set the e.Effect property on the 'DragEnter' event as specified in
http://msdn.microsoft.com/en-us/library/aa984430(v=vs.71).aspx

Drag and Drop not working in C# Winforms Application

Is your DragDropEffect set appropriately? Try placing this in the DragEnter Event Handler Method:

    private void Form1_DragEnter(object sender, DragEventArgs e)
{
Console.WriteLine("DragEnter!");
e.Effect = DragDropEffects.Copy;
}

By default it was set to DragDropEffects.None so the Drop event wouldn't fire.

Drag'n'drop to a Windows form issue

By default the target drop effect of a drag-and-drop operation is not specified (DragDropEffects.None). Thus there is no drop event for your control in this case.
To allow Control to be a drag-and-drop operation's receiver for the specific data you should specify the concrete DardDropEffect as shown below (use the DragEnter or DragOver events):

void Form1_DragDrop(object sender, DragEventArgs e) {
object data = e.Data.GetData(DataFormats.FileDrop);
}
void Form1_DragEnter(object sender, DragEventArgs e) {
if(e.Data.GetDataPresent(DataFormats.FileDrop)) {
e.Effect = DragDropEffects.Copy;
}
}

Related MSDN article: Performing a Drag-and-Drop Operation in Windows Forms

Drag'n'Drop in form still disabled

Okay, this post was the one to read.
Closed and re-launched VisualStudio without Administrator rights, it works :(

Drag and drop from Windows File Explorer onto a Windows Form is not working

The problem comes from Vista's UAC. DevStudio is running as administrator, but explorer is running as a regular user. When you drag a file from explorer and drop it on your DevStudio hosted application, that is the same as a non-privileged user trying to communicate with a privileged user. It's not allowed.

This will probably not show up when you run the app outside of the debugger. Unless you run it as an administrator there (or if Vista auto-detects that it's an installer/setup app).

You could also run explorer as an admin, at least for testing. Or disable UAC (which I would not recommend, since you really want to catch these issues during development, not during deployment!)



Related Topics



Leave a reply



Submit