2014-10-31 57 views
0

通常情况下,这个属性是sufficent(短版):还是中拖放禁用

namespace DiapoWin 
{ 
    partial class mainWindow 
    { 
     private void InitializeComponent() 
     { 
      this.AllowDrop = true; 

的AllowDrop设置为true的主要形式,并列表框(应该是目标拖/放)。

这里是我的事件处理程序(从this后):

private void listImages1_DragDrop(object sender, DragEventArgs e) 
{ 
    if (e.Data.GetDataPresent(DataFormats.FileDrop)) 
    { 
     string[] fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); 
     TextDelai.Lines = fileNames; 
    } 
} 

private void listImages1_DragEnter(object sender, DragEventArgs e) 
{ 
    if (e.Data.GetDataPresent(DataFormats.FileDrop)) 
    { 
     e.Effect = DragDropEffects.Copy; 
    } 
} 

但尝试删除一个文件夹(即使有文件)时,我仍然收到forbidden鼠标光标。 任何想法?

+0

[如何将文件拖放到C#应用程序?](http://stackoverflow.com/questions/68598/how-do-i -drag-and-drop-files-into-ac-sharp-application) – 2014-10-31 16:56:59

+0

你正在处理DragOver吗?http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dragover (v = vs.110).aspx – WraithNath 2014-10-31 16:57:02

+0

我刚刚添加了一个精度:创建所有事件处理程序:( – madoxav 2014-10-31 16:59:05

回答

0

好的,this后是一个阅读。 关闭并重新启动没有管理员权限的VisualStudio,它的工作原理:(