views:

126

answers:

1

The application that I am developing is a windows form application written in C#. It has a treeview on it. Each of the treeNode stores some data. What I want to do is to open two copies of the application, drag some of the treenodes from one application and drop to another. The data the treenodes store should be transferred to another application to build treenodes on another application. I wonder how to implement the drag and drop functionality like this? Thanks for your help.

A: 

I think if you mark your types as [Serializable] AND implement custom serialization, it should work. Otherwise, you can serialize them yourself to a MemoryStream and then add that MemoryStream to the data object using any custom data format.

logicnp
Could you explain it in more details? If I serialized them in a memory stream when dragging, can I get data from the memory stream when dropping in another process?
telescope
yes, add it to the source data object before calling DoDragDrop. In the target's DragEnter/DragOver/DragDrop event, retirve this data. Be sure to specify the same data format you used when adding the data.
logicnp
Thanks. It works.
telescope