private void treeView_ItemDrag(object sender, ItemDragEventArgs e)
{
try
{
IVariable variable = getSelectedNode();
this.treeView.DoDragDrop((Variable)variable, DragDropEffects.Copy);
}
catch (Exception) { }
}
private void splitContainer_Panel2_DragDrop(object sender, DragEventArgs e)
{
Variable var = (Variable)(e.Data);
}
The Variable is a variable object (singleton pattern). I want this object dragged from a treeview to a other view (to draw the object).
I get this error code:
The object of type “System.Windows.Forms.DataObject” can not be converted to type ‘ORANGE_VARIABLE.Variable “.
I have the right Object inside the data.form.
How can I unwrap this object?
When you call
DoDragDrop, yourVariableobject is automatically wrapped in aDataObject. To retrieve it, you need to callGetDatawith the type of the data you want to retrieve: