|
-
November 22nd, 2004, 05:01 AM
#1
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.
-
November 22nd, 2004, 11:03 AM
#2
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));
Useful? Then click on (Rate This Post) at the top of this post.
-
June 13th, 2005, 07:51 AM
#3
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
-
April 17th, 2007, 02:40 AM
#4
Re: Problems copying object to clipboard
I`m having the exact same problem after doing everything mentioned here. Anyone els has found a solution?
-
April 17th, 2007, 03:10 AM
#5
Re: Problems copying object to clipboard
Show us some code.
Laitinen
-
April 17th, 2007, 09:27 PM
#6
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...
-
April 17th, 2007, 09:35 PM
#7
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
Last edited by Traps; April 17th, 2007 at 09:39 PM.
-
April 17th, 2007, 11:51 PM
#8
Re: Problems copying object to clipboard
Ah, thanks for the input. That might be the problem
-
April 18th, 2007, 01:36 AM
#9
Re: Problems copying object to clipboard
 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|