Clipboard to copy Treenode

F

fred

I am using the clipboard to copy and paste a TreeNode but the Tag property
does not seem to be copied.
I use the Tag property for an Object that contains data relating to the
TreeNode. The Tag property is fine when the TreeNode is put onto the
Clipboard but the Tag property is always 'nothing' when I take the TreeNode
from the Clipboard.

Private Sub PutNodeOnClipboard(ByVal thisNode As TreeNode)
Dim thisDataObject As New DataObject
thisDataObject.SetData(myFormat.Name, thisNode)
Clipboard.SetDataObject(thisDataObject)
End Sub

Private Sub MIEdit_Paste_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MIEdit_Paste.Click
Dim myClipData As IDataObject = Clipboard.GetDataObject()
If myClipData.GetDataPresent(myFormat.Name) Then
Dim NodeFromClip As TreeNode = _
CType(myClipData.GetData(myFormat.Name, True), TreeNode)
....
This last line of code takes the TreeNode from the clipboard and all the
properties seem fine except the Tag property.
What do I need to do to ensure the Tag property follows the TreeNode via
Clipboard.

Thanks
Fred
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top