C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-16-2004, 03:25 PM   #1
Registered User
 
Join Date: Sep 2004
Posts: 3
Clipboard and Custom Types

Hello,
I've been trying like crazy to figure out how to copy an object of a custom type to the Clipboard via Clipboard.SetDataObject() and then retrieve it with Clipboard.GetDataObject().

I've tried everything I can think of. I declare a DataObject, made out of my custom object, and give it a format name, and send it to the clipboard. Then I bring it back from the clipboard, as an IDataObject, use GetDataPresent(*format name", true), and it says that the data is present. But when I use GetData, it returns null! What is going on here?

There are many demos about how to use the clipboard with strings and bitmaps but that's pretty useless. What's the point of C#'s clipboard support if all you can do is transfer bitmaps? I can post code if anyone is interested.
McClamm is offline   Reply With Quote
Old 09-16-2004, 04:43 PM   #2
BMJ
Registered User
 
Join Date: Aug 2002
Posts: 1,330
If you want to use custom objects with the managed clipboard functions, the object must be declared as [Serializable()].

Code:
[Serializable()]
public class CustomData
{
... blah blah blah ...
}
Basically when custom objects are sent to the clipboard they're serialized, and then the clipboard holds the binary data.
BMJ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 09:57 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22