I posted before to no avail, but here goes:
Suppose I want to copy an object (an instance of my class, or of a listbox's items, or anything else other than text or images) to the clipboard. Documentation says that it's possible but it for me it seems I can never retrieve it. Here's code:
Here's an example:
(Assuming I want to copy the contents of the listbox: List1)
Private Sub btnCopy_Click(....)
'To copy the listbox items
Clipboard.SetDataObject(cmb1.Items)
btnPaste.Enabled = True
End Sub
Private Sub btnPaste_Click(...)
' to paste the listbox items
Dim Data As IDataObject = Clipboard.GetDataObject
Dim C As ComboBox.ObjectCollection = Data.GetData(GetType(ComboBox.ObjectCollection))
Dim O as object
'The next line causes the NullReference error
For Each O in C
...
Next
End Sub
Try copying and retrieving an object from the clipboard and let me know if you have any success. Thanks in advance.
Suppose I want to copy an object (an instance of my class, or of a listbox's items, or anything else other than text or images) to the clipboard. Documentation says that it's possible but it for me it seems I can never retrieve it. Here's code:
Here's an example:
(Assuming I want to copy the contents of the listbox: List1)
Private Sub btnCopy_Click(....)
'To copy the listbox items
Clipboard.SetDataObject(cmb1.Items)
btnPaste.Enabled = True
End Sub
Private Sub btnPaste_Click(...)
' to paste the listbox items
Dim Data As IDataObject = Clipboard.GetDataObject
Dim C As ComboBox.ObjectCollection = Data.GetData(GetType(ComboBox.ObjectCollection))
Dim O as object
'The next line causes the NullReference error
For Each O in C
...
Next
End Sub
Try copying and retrieving an object from the clipboard and let me know if you have any success. Thanks in advance.