GetDataPresent and interfaces (DragDrop)

  • Thread starter Thread starter Chetan Mistry
  • Start date Start date
C

Chetan Mistry

Is is possible to check to see during a drag drop operation if the
object being dropped implements a particular interface?

For example, if I have the following class which implements
IMyInterface:

class MyClass : IMyInterface
{
// implementation ommitted
}

Then when I start dragging I call DoDragDrop() like this:

MyClass myClass = new myClass();
IMyInterface myInterface = myClass as IMyInterface;
DoDragDrop( myInterface, DragDropEffects.Copy );

Then when I get my DragEnter event I want to check if the data
supplied implements IMyInterface. e.g.

if ( e.Data.GetDataPresent( typeof (IMyInterface) ) .....

This returns false but if a do "typeof(MyClass) it works fine.

How can I check to see if the item being dropped implements a specific
interface?

Thanks.
Chet
 
Back
Top