I have 2 controls one one form: list and a tree (specific type names are irrelevant).
In the list control I execute DoDragDrop method. As the first argument I pass an object which was data bound to that row. The object implements a specific interface and is marked with Serializable attribute.
What I want is to retreive that object in DragEnter/DragDrop event handler of the tree control. I'm using the following code:
void TreeControlDragEnter(object sender, DragEventArgs e)
{
var formats = e.Data.GetFormats();
var data = e.Data.GetData(typeof (IFoo));
}
Unfortunately, in result data is null and formats is an one-element array which holds the name of the specific type (implementing IFoo). I assume that I would have to pass exact type name to GetData to retreve the object, but it's not possible as it is a private class.
Is there a way to get the object by its interface?