c# - e.Data.GetDataPresent not working in WinForms drag-and-drop handler? -


I am trying to drag files into my application, which is trying to pull from Locate32 (the way great is). What happens here:

  e.Data.GetFormats () {string [7]} [0]: "file drop" [1]: "filename" [2]: "filename" [3]: "Filename Map" [4]: ​​"Filename MapWatch" [5]: "Shell Illustrator Array" [6]: "Shell Object Offsets" Data Format. Filedrop "FileDrop" eData .adata (data format.filedrop) False  

Why e Data Gate Data Present (Dataformat.philoop) Return false Even if the file draft is one of clearly listed forms "Available"

If I E. Data. I get a list of file names, as I should do, drag and drop works fine with Windows Explorer.

Here is the code for my dragent handler:

  Private zero myForm_DragEnter (Object Sender, DragEventArgs e) {if (e.Data.GetDataPresent (DataFormats.FileDrop)) {Affix = dragprofefs.copy; } And {e. Effect = drag effect; }}  

If you have DragDropEffects.Copy in the list .

Update

Some time ago I had some problems getting the right look from GetDataPresent () . Due to this fact, I just looked directly at the list provided by GetFormats () and the code I had on myself was something like this:

  Private Zero Owned Daggent (Object) Sender, DragEventAgps, E) {// Get the first format from the list and try to enter it in the desired type // Var list = e.Data.GetData (e.Data.GetFormats () [0]) as IEnumerable & lt; ListViewItem & gt; If (list! = Null) {e.ffect = DragDropEffects.Copy; } And {e. Effect = drag effect; }}  

This simple solution works for me, but you can also run GetFormats () with linax and find your desired type Or something similar


Comments