Drag and Drop a file

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
 
F

Family Tree Mike

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top