Drag and Drop a file

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hi!

I just wonder what point is it to use this statement
bool status = e.Data.GetDataPresent(DataFormats.FileDrop);
because this statement always return true when I drag and drop a file ?
Can somebody say in what situations will this statement return false ?

private void OnDragEnter(object sender, System.Windows.Forms.DragEventArgs
e)
{
bool status = e.Data.GetDataPresent(DataFormats.FileDrop);
....
....
}

//Tony
 
Hi!

I just wonder what point is it to use this statement
bool status = e.Data.GetDataPresent(DataFormats.FileDrop);
because this statement always return true when I drag and drop a file ?
Can somebody say in what situations will this statement return false ?

private void OnDragEnter(object sender, System.Windows.Forms.DragEventArgs
e)
{
bool status = e.Data.GetDataPresent(DataFormats.FileDrop);
...
...
}

//Tony

It would return false if you are dragging something that is not a file.
Take for example if you have a listbox containing a list of objects
from some class specific to your application such as MyObject. The
value of status would be false, and you would know to get the data by
other means, or ignore the drop, depending on your application's goal.
 
Back
Top