2014-10-31 61 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,它的工作原理:(