List Of TreeNode in Clipboard ?

Hello EE,

I have a list(Of TreeNode) when the user press CTRL+C i would like to put all the Selectednodes of a Treeview in the ClipBoard

then if CTRL+V I would like to retrieve them


can you help? Im having difficulties
LVL 1
PhilippeRenaudAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Here's a quick example:
        Dim DataNameConstant As String = "MyTreeNodeList"

        Dim nodes As New List(Of TreeNode)
        nodes.Add(New TreeNode("a"))
        nodes.Add(New TreeNode("b"))
        nodes.Add(New TreeNode("c"))

        Clipboard.SetData(DataNameConstant, nodes)
        nodes = Nothing

        nodes = DirectCast(Clipboard.GetData(DataNameConstant), List(Of TreeNode))
        For Each node As TreeNode In nodes
            Debug.Print(node.Text)
        Next

Open in new window

0
 
käµfm³d 👽Commented:
Idle_Mind's solution is certainly what you should be doing--so long as you understand that you are going to be pasting the binary-serialized version of the List. It's not going to simply paste into Notepad as a list of items. If you want to paste this data into, say, a text editor, then you will need to format the data with newlines and place it into the clipboard as a string.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Yeah...as I posted that I was wondering how the copy/paste is going to be utilized in the end product.
0
 
PhilippeRenaudAuthor Commented:
Yup, I understand. Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.