Hi,
I've implemented drag/drop between instances of the same sub-classed TreeView passing a reference to the TreeView itself as the DataObject. So starting the drag I have :
DataObject d = new DataObject(typeof(SWC.TreeView), this);
const DragDropEffects de = DragDropEffects.Copy;
DragDrop.DoDragDrop(this, d, de);
and in OnDrop():
if (e.Data.GetDataPresent(typeof(SWC.TreeView)))
SWC.TreeView t = (SWC.TreeView)e.Data.GetData(typeof(SWC.TreeView));
This works fine between TreeViews within the same instance of the application but when used between instances the GetData() line throws a ComException 'Invalid tymed'.
I *think* this is because COM only supports a fixed number of formats for drag/drop (and obviously my class is not amongst them :-{ )
(
http://msdn.microsoft.com/en-us/library/ms691227(VS.85).aspx)Any suggestions for a workaround?
(This is actually in WPF but AFAIK the DragDrop is the same as in WinForms)