I\'m using drgevent.Data.GetDataPresent to determine whether the dragged component is acceptable or not.
I\'ve got a problem which is that I want to accept a specifi
I have answered a similar question previously: C# Drag and Drop - e.Data.GetData using a base class
What you can do is create a container class which holds the data that you are dragging. And then in the GetDataPresent you check for the container class type and if it is present then you can read the content member which contains the actual instance of your data.
Here is an quick example, if your base type is DragDropBaseData, you can create the following DragDropInfo class.
public class DragDropInfo
{
public DragDropBaseData Value { get; private set; }
public DragDropInfo(DragDropBaseData value)
{
this.Value= value;
}
}
And then the drag drop can be initiated with the following, where DrafDropDerivedData is a class derived from DragDropBaseData.
DoDragDrop(new DragDropInfo(new DragDropDerivedData() ), DragDropEffects.All);
And you can access the data in the drag events using the following
e.Data.GetData(typeof(DragDropInfo));