Getting own class from clipboard trouble.

aewarnick

Senior Contributor
Joined
Jan 29, 2003
Messages
1,031
I have tried everything in getting my own class called a.graphics.WrappedBmp out of the clipboad. Here is the current code which I thought was most likely to work:
C#:
string type= Clipboard.GetDataObject().GetFormats()[0];
a.graphics.WrappedBmp wb= (a.graphics.WrappedBmp)Clipboard.GetDataObject().GetData(this.selWB.GetType());

GetData(this.selWB.GetType()); is where my trouble is.

selWB is of type a.graphics.WrappedBmp.
and
GetFormats()[0] confirms that the data in the clipboard is of that type.

I have tried many things including different strings to represent the data type including the very one returned by GetFormats() and nothing works.

I have tried typeof(a.graphics.WrappedBmp) but to no success at all.
 
Clipboard doesn't return the object on the clipboard, it returns a DataObject class which contains information about the object. Perhaps you should try looking at that in the MSDN. Plus, the MSDN has numerous samples about the clipboard.
 
Actually I found that all I had to do was put [Serializable] above my class and walla! It works.
 
Back
Top