Problems copying object to clipboard
Hello.
We have a problem copying an object to the clipboard.
to do this, we write: Clipboard.SetDataObject(o)
where o is our object.
Our object is inherited from UserControl.
When we try to retrieve the object from the clipboard, it is of the right type, but it is null.
Re: Problems copying object to clipboard
The object that is added to the Clipboard needs to be serializable. eg.
Code:
[Serializable]
public class YourData
{
.
.
}
Clipboard.SetDataObject(new DataObject(new YourData()));
IDataObject dataObject = Clipboard.GetDataObject();
object data = dataObject.GetData(typeof(YourData));
Re: Problems copying object to clipboard
What if the object is serilizable and it returns null anyway. Anyone have any idea what is wrong?
Thanks
Anders
Re: Problems copying object to clipboard
I`m having the exact same problem after doing everything mentioned here. Anyone els has found a solution?
Re: Problems copying object to clipboard
Show us some code.
Laitinen
Re: Problems copying object to clipboard
this is the object i`m trying to place on the clipboard
Code:
[Serializable]
public abstract class PageItem : UserControl
{
}
to place the object on the clipboard, i do this
Code:
Clipboard.SetData ( "PageItem", pageItemObject ) ;
The following method call returns true
Code:
Clipboard.ContainsData ( "PageItem" ) ;
However, when i do this, it returns null
Code:
Clipboard.GetData ( "PageItem" ) ;
Can`t figure out why...
Re: Problems copying object to clipboard
I'm sorry I dont mean to clog up your thread, I'm still very new to c#.
I just got done serializing a generic queue of struct's. In my reading it says you cant serialize an inherited class. Does that help any?
http://msdn2.microsoft.com/en-us/lib...attribute.aspx
Re: Problems copying object to clipboard
Ah, thanks for the input. That might be the problem
Re: Problems copying object to clipboard
Quote:
Originally Posted by Traps
I just got done serializing a generic queue of struct's. In my reading it says you cant serialize an inherited class.[/url]
Well you cannot serialize a class that is inherited from a class that does not implement serializing. Therefore you can not serialize a class that inherits from UserControl.
Regards,
Laitinen