Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying objects to the CLIPBOARD

Status
Not open for further replies.

VBMental

Programmer
Feb 26, 2002
14
0
0
US
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top