In certain cases I need to determine a type and I just don’t know what the type is. For example, DevExpress plugins request a type when getting data.
e.Data.GetDataPresent(typeof(DataRow))
I set the data source as a DataTable. I don’t know if the data present is actually a String, DataRow, DataColumn or other.
Is there any way to determine this type without having to hack at all the possibilties one by one in the debugger/Immediate window?
UPDATE
In this case it’s a winform app event
private void grid_VDragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(DataColumn)))//DataColumn is just a guess..no idea
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
}
You can use
object.GetType()– all objects implement it, so you can simply use that:Update:
With the revision (drag drop data accessible only through
IDataObjectand no variable), this answer is of limited use to the OP. I will keep it here for those whom it might help that do not have these exact constraints.