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
Matt Berther - 18 Sep 2004 20:06 GMT
Hello Chetan,
The is keyword...
if (myVar is IMyInterface)
{
// do something
}
--
Matt Berther
http://www.mattberther.com
> Is is possible to check to see during a drag drop operation if the
> object being dropped implements a particular interface?
[quoted text clipped - 23 lines]
> Thanks.
> Chet