By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

How to Copy/Paste to clipboard ??

P: n/a
Dear all,

I have an treeview control with different node object, I would like to
implement the Copy/Paste function of an object . For that I am using the
folowing function to copy teh object to clipboard :

====>
Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.GetFormat("ReportFormat")

' Creates a new object and store it in a DataObject using
myFormat
' as the type of format.

Dim m_ReportObject As New DataObject(m_ClipObjFormat.Name, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDataObject(m_ReportObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipboard(ByVal ObjFormat As DataFormats.Format)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObject As IDataObject = Clipboard.GetDataObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedObject As PluginApp.PlugInReport = _
CType(m_RetrievedObject.GetData(ObjFormat.Name),
PluginApp.PlugInReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedObject
End Sub
<=======

Problem I have with that is that when I read back the clipboad I get an
empty object.
Either the object has never been copied or not read back properly.

WHat is wrong ?

thanks for help
serge
Nov 22 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On Wed, 22 Nov 2006 06:11:02 -0800, serge calderara wrote:
Dear all,

I have an treeview control with different node object, I would like to
implement the Copy/Paste function of an object . For that I am using the
folowing function to copy teh object to clipboard :

====>
Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.GetFormat("ReportFormat")

' Creates a new object and store it in a DataObject using
myFormat
' as the type of format.

Dim m_ReportObject As New DataObject(m_ClipObjFormat.Name, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDataObject(m_ReportObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipboard(ByVal ObjFormat As DataFormats.Format)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObject As IDataObject = Clipboard.GetDataObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedObject As PluginApp.PlugInReport = _
CType(m_RetrievedObject.GetData(ObjFormat.Name),
PluginApp.PlugInReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedObject
End Sub
<=======

Problem I have with that is that when I read back the clipboad I get an
empty object.
Either the object has never been copied or not read back properly.

WHat is wrong ?

thanks for help
serge
I have never been able to pass an object in the clipboard, and I think this
is by design. The only solution is to serialize the object and put that in
the clipboard.
I do this for our system, and the advantage is that you then allow pasting
between different applications without requiring the same DLLs be shared.
You also have to do this to drag-drop between applications, as this uses
the same concepts as cut/paste.

I create my own serializable DragData Object that contains all the info I
want to cut/paste, and this allows me to create a tidy 'packet' with all
the associated metadata to reconstruct my objects when deserialized.

Cheers,
Gadget
Nov 22 '06 #2

P: n/a
Thnaks for your reply.
I have never done this, could you brifly explain me hoe to do it ?

regards
serge

"Gadget" wrote:
On Wed, 22 Nov 2006 06:11:02 -0800, serge calderara wrote:
Dear all,

I have an treeview control with different node object, I would like to
implement the Copy/Paste function of an object . For that I am using the
folowing function to copy teh object to clipboard :

====>
Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.GetFormat("ReportFormat")

' Creates a new object and store it in a DataObject using
myFormat
' as the type of format.

Dim m_ReportObject As New DataObject(m_ClipObjFormat.Name, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDataObject(m_ReportObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipboard(ByVal ObjFormat As DataFormats.Format)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObject As IDataObject = Clipboard.GetDataObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedObject As PluginApp.PlugInReport = _
CType(m_RetrievedObject.GetData(ObjFormat.Name),
PluginApp.PlugInReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedObject
End Sub
<=======

Problem I have with that is that when I read back the clipboad I get an
empty object.
Either the object has never been copied or not read back properly.

WHat is wrong ?

thanks for help
serge

I have never been able to pass an object in the clipboard, and I think this
is by design. The only solution is to serialize the object and put that in
the clipboard.
I do this for our system, and the advantage is that you then allow pasting
between different applications without requiring the same DLLs be shared.
You also have to do this to drag-drop between applications, as this uses
the same concepts as cut/paste.

I create my own serializable DragData Object that contains all the info I
want to cut/paste, and this allows me to create a tidy 'packet' with all
the associated metadata to reconstruct my objects when deserialized.

Cheers,
Gadget
Nov 23 '06 #3

P: n/a
On Wed, 22 Nov 2006 23:37:01 -0800, calderara wrote:
Thnaks for your reply.
I have never done this, could you brifly explain me hoe to do it ?

regards
serge

"Gadget" wrote:
>On Wed, 22 Nov 2006 06:11:02 -0800, serge calderara wrote:
>>Dear all,

I have an treeview control with different node object, I would like to
implement the Copy/Paste function of an object . For that I am using the
folowing function to copy teh object to clipboard :

====>
Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.GetFormat("ReportFormat")

' Creates a new object and store it in a DataObject using
myFormat
' as the type of format.

Dim m_ReportObject As New DataObject(m_ClipObjFormat.Name, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDataObject(m_ReportObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipboard(ByVal ObjFormat As DataFormats.Format)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObject As IDataObject = Clipboard.GetDataObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedObject As PluginApp.PlugInReport = _
CType(m_RetrievedObject.GetData(ObjFormat.Name),
PluginApp.PlugInReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedObject
End Sub
<=======

Problem I have with that is that when I read back the clipboad I get an
empty object.
Either the object has never been copied or not read back properly.

WHat is wrong ?

thanks for help
serge

I have never been able to pass an object in the clipboard, and I think this
is by design. The only solution is to serialize the object and put that in
the clipboard.
I do this for our system, and the advantage is that you then allow pasting
between different applications without requiring the same DLLs be shared.
You also have to do this to drag-drop between applications, as this uses
the same concepts as cut/paste.

I create my own serializable DragData Object that contains all the info I
want to cut/paste, and this allows me to create a tidy 'packet' with all
the associated metadata to reconstruct my objects when deserialized.

Cheers,
Gadget
Look here:
http://support.microsoft.com/kb/815813
and a whole thread on using strings (which is what you want)
http://www.thescripts.com/forum/thread175771.html

Remember, "Google is your friend".

Cheers,
Gadget
Nov 23 '06 #4

P: n/a
Thnaks for the links.
I have try to implement but when I create a new XMLSerializer object, then I
get an exception error saying "Error reflecting type PluginApp.PlugInReport"

here is my code

=====>
Dim s As System.Xml.Serialization.XmlSerializer = New
System.Xml.Serialization.XmlSerializer(GetType(Plu ginApp.PlugInReport))

Dim txtWriter As System.IO.TextWriter = New
System.IO.StreamWriter("f:\report.xml")

s.Serialize(txtWriter, CType(tvReport.SelectedNode.Tag,
PluginApp.PlugInReport))
I have set for the class that I want to serialize a <Serializableattributes
<<<<<=====
Any idea what is wrong ?
Do I miss something
regards
serge

"Gadget" wrote:
On Wed, 22 Nov 2006 23:37:01 -0800, calderara wrote:
Thnaks for your reply.
I have never done this, could you brifly explain me hoe to do it ?

regards
serge

"Gadget" wrote:
On Wed, 22 Nov 2006 06:11:02 -0800, serge calderara wrote:

Dear all,

I have an treeview control with different node object, I would like to
implement the Copy/Paste function of an object . For that I am using the
folowing function to copy teh object to clipboard :

====>
Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.GetFormat("ReportFormat")

' Creates a new object and store it in a DataObject using
myFormat
' as the type of format.

Dim m_ReportObject As New DataObject(m_ClipObjFormat.Name, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDataObject(m_ReportObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipboard(ByVal ObjFormat As DataFormats.Format)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObject As IDataObject = Clipboard.GetDataObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedObject As PluginApp.PlugInReport = _
CType(m_RetrievedObject.GetData(ObjFormat.Name),
PluginApp.PlugInReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedObject
End Sub
<=======

Problem I have with that is that when I read back the clipboad I get an
empty object.
Either the object has never been copied or not read back properly.

WHat is wrong ?

thanks for help
serge

I have never been able to pass an object in the clipboard, and I think this
is by design. The only solution is to serialize the object and put that in
the clipboard.
I do this for our system, and the advantage is that you then allow pasting
between different applications without requiring the same DLLs be shared.
You also have to do this to drag-drop between applications, as this uses
the same concepts as cut/paste.

I create my own serializable DragData Object that contains all the info I
want to cut/paste, and this allows me to create a tidy 'packet' with all
the associated metadata to reconstruct my objects when deserialized.

Cheers,
Gadget

Look here:
http://support.microsoft.com/kb/815813
and a whole thread on using strings (which is what you want)
http://www.thescripts.com/forum/thread175771.html

Remember, "Google is your friend".

Cheers,
Gadget
Nov 24 '06 #5

P: n/a
On Fri, 24 Nov 2006 01:30:01 -0800, calderara wrote:
Thnaks for the links.
I have try to implement but when I create a new XMLSerializer object, then I
get an exception error saying "Error reflecting type PluginApp.PlugInReport"

here is my code

=====>
Dim s As System.Xml.Serialization.XmlSerializer = New
System.Xml.Serialization.XmlSerializer(GetType(Plu ginApp.PlugInReport))

Dim txtWriter As System.IO.TextWriter = New
System.IO.StreamWriter("f:\report.xml")

s.Serialize(txtWriter, CType(tvReport.SelectedNode.Tag,
PluginApp.PlugInReport))
I have set for the class that I want to serialize a <Serializableattributes
<<<<<=====
Any idea what is wrong ?
Do I miss something
regards
serge

"Gadget" wrote:
>On Wed, 22 Nov 2006 23:37:01 -0800, calderara wrote:
>>Thnaks for your reply.
I have never done this, could you brifly explain me hoe to do it ?

regards
serge

"Gadget" wrote:

On Wed, 22 Nov 2006 06:11:02 -0800, serge calderara wrote:

Dear all,
>
I have an treeview control with different node object, I would like to
implement the Copy/Paste function of an object . For that I am using the
folowing function to copy teh object to clipboard :
>
====>
Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport)
>
' Creates a new data format.
m_ClipObjFormat = DataFormats.GetFormat("ReportFormat")
>
' Creates a new object and store it in a DataObject using
myFormat
' as the type of format.
>
Dim m_ReportObject As New DataObject(m_ClipObjFormat.Name, Obj)
>
' Copies myObject into the clipboard.
Clipboard.SetDataObject(m_ReportObject)
End Sub
<=====
>
and the following object to get it back from clipboard
>
===>
Private Sub PasteFromClipboard(ByVal ObjFormat As DataFormats.Format)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObject As IDataObject = Clipboard.GetDataObject()
>
' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedObject As PluginApp.PlugInReport = _
CType(m_RetrievedObject.GetData(ObjFormat.Name),
PluginApp.PlugInReport)
>
' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedObject
End Sub
<=======
>
Problem I have with that is that when I read back the clipboad I get an
empty object.
Either the object has never been copied or not read back properly.
>
WHat is wrong ?
>
thanks for help
serge

I have never been able to pass an object in the clipboard, and I think this
is by design. The only solution is to serialize the object and put that in
the clipboard.
I do this for our system, and the advantage is that you then allow pasting
between different applications without requiring the same DLLs be shared.
You also have to do this to drag-drop between applications, as this uses
the same concepts as cut/paste.

I create my own serializable DragData Object that contains all the info I
want to cut/paste, and this allows me to create a tidy 'packet' with all
the associated metadata to reconstruct my objects when deserialized.

Cheers,
Gadget

Look here:
http://support.microsoft.com/kb/815813
and a whole thread on using strings (which is what you want)
http://www.thescripts.com/forum/thread175771.html

Remember, "Google is your friend".

Cheers,
Gadget
You will have to find what it is in your PlugInReport that is not
serializable. Simply setting the attribute is not enough.
Look at the details in the exception to find why it couldn't serialize it.

Cheers,
Gadget
Nov 24 '06 #6

P: n/a
Hi

I have still one question. I can control class reference or object of my own
to verify if there are serializable or not but if my library is using for
instance Crystal report reference object, I cannot change anything in that
library if it is not serializable...

What to do then ?

thnaks for help
regards

"Gadget" wrote:
On Fri, 24 Nov 2006 01:30:01 -0800, calderara wrote:
Thnaks for the links.
I have try to implement but when I create a new XMLSerializer object, then I
get an exception error saying "Error reflecting type PluginApp.PlugInReport"

here is my code

=====>
Dim s As System.Xml.Serialization.XmlSerializer = New
System.Xml.Serialization.XmlSerializer(GetType(Plu ginApp.PlugInReport))

Dim txtWriter As System.IO.TextWriter = New
System.IO.StreamWriter("f:\report.xml")

s.Serialize(txtWriter, CType(tvReport.SelectedNode.Tag,
PluginApp.PlugInReport))
I have set for the class that I want to serialize a <Serializableattributes
<<<<<=====
Any idea what is wrong ?
Do I miss something
regards
serge

"Gadget" wrote:
On Wed, 22 Nov 2006 23:37:01 -0800, calderara wrote:

Thnaks for your reply.
I have never done this, could you brifly explain me hoe to do it ?

regards
serge

"Gadget" wrote:

On Wed, 22 Nov 2006 06:11:02 -0800, serge calderara wrote:

Dear all,

I have an treeview control with different node object, I would like to
implement the Copy/Paste function of an object . For that I am using the
folowing function to copy teh object to clipboard :

====>
Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.GetFormat("ReportFormat")

' Creates a new object and store it in a DataObject using
myFormat
' as the type of format.

Dim m_ReportObject As New DataObject(m_ClipObjFormat.Name, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDataObject(m_ReportObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipboard(ByVal ObjFormat As DataFormats.Format)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObject As IDataObject = Clipboard.GetDataObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedObject As PluginApp.PlugInReport = _
CType(m_RetrievedObject.GetData(ObjFormat.Name),
PluginApp.PlugInReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedObject
End Sub
<=======

Problem I have with that is that when I read back the clipboad I get an
empty object.
Either the object has never been copied or not read back properly.

WHat is wrong ?

thanks for help
serge

I have never been able to pass an object in the clipboard, and I think this
is by design. The only solution is to serialize the object and put that in
the clipboard.
I do this for our system, and the advantage is that you then allow pasting
between different applications without requiring the same DLLs be shared.
You also have to do this to drag-drop between applications, as this uses
the same concepts as cut/paste.

I create my own serializable DragData Object that contains all the info I
want to cut/paste, and this allows me to create a tidy 'packet' with all
the associated metadata to reconstruct my objects when deserialized.

Cheers,
Gadget
Look here:
http://support.microsoft.com/kb/815813
and a whole thread on using strings (which is what you want)
http://www.thescripts.com/forum/thread175771.html

Remember, "Google is your friend".

Cheers,
Gadget

You will have to find what it is in your PlugInReport that is not
serializable. Simply setting the attribute is not enough.
Look at the details in the exception to find why it couldn't serialize it.

Cheers,
Gadget
Nov 27 '06 #7

P: n/a
On Sun, 26 Nov 2006 23:53:01 -0800, calderara wrote:
Hi

I have still one question. I can control class reference or object of my own
to verify if there are serializable or not but if my library is using for
instance Crystal report reference object, I cannot change anything in that
library if it is not serializable...

What to do then ?

thnaks for help
regards

"Gadget" wrote:
>On Fri, 24 Nov 2006 01:30:01 -0800, calderara wrote:
>>Thnaks for the links.
I have try to implement but when I create a new XMLSerializer object, then I
get an exception error saying "Error reflecting type PluginApp.PlugInReport"

here is my code

=====>
Dim s As System.Xml.Serialization.XmlSerializer = New
System.Xml.Serialization.XmlSerializer(GetType(P luginApp.PlugInReport))

Dim txtWriter As System.IO.TextWriter = New
System.IO.StreamWriter("f:\report.xml")

s.Serialize(txtWriter, CType(tvReport.SelectedNode.Tag,
PluginApp.PlugInReport))
I have set for the class that I want to serialize a <Serializableattributes
<<<<<=====
Any idea what is wrong ?
Do I miss something
regards
serge

"Gadget" wrote:

On Wed, 22 Nov 2006 23:37:01 -0800, calderara wrote:

Thnaks for your reply.
I have never done this, could you brifly explain me hoe to do it ?
>
regards
serge
>
"Gadget" wrote:
>
>On Wed, 22 Nov 2006 06:11:02 -0800, serge calderara wrote:
>>
>>Dear all,
>>>
>>I have an treeview control with different node object, I would like to
>>implement the Copy/Paste function of an object . For that I am using the
>>folowing function to copy teh object to clipboard :
>>>
>>====>
>>Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport)
>>>
>> ' Creates a new data format.
>> m_ClipObjFormat = DataFormats.GetFormat("ReportFormat")
>>>
>> ' Creates a new object and store it in a DataObject using
>>myFormat
>> ' as the type of format.
>>>
>> Dim m_ReportObject As New DataObject(m_ClipObjFormat.Name, Obj)
>>>
>> ' Copies myObject into the clipboard.
>> Clipboard.SetDataObject(m_ReportObject)
>> End Sub
>><=====
>>>
>>and the following object to get it back from clipboard
>>>
>>===>
>>Private Sub PasteFromClipboard(ByVal ObjFormat As DataFormats.Format)
>> ' Performs some processing steps.
>> ' Retrieves the data from the clipboard.
>> Dim m_RetrievedObject As IDataObject = Clipboard.GetDataObject()
>>>
>> ' Converts the IDataObject type to MyNewObject type.
>> Dim myDereferencedObject As PluginApp.PlugInReport = _
>> CType(m_RetrievedObject.GetData(ObjFormat.Name),
>>PluginApp.PlugInReport)
>>>
>> ' Print the value of the Object in a textBox.
>> m_PasteObject = myDereferencedObject
>> End Sub
>><=======
>>>
>>Problem I have with that is that when I read back the clipboad I get an
>>empty object.
>>Either the object has never been copied or not read back properly.
>>>
>>WHat is wrong ?
>>>
>>thanks for help
>>serge
>>
>I have never been able to pass an object in the clipboard, and I think this
>is by design. The only solution is to serialize the object and put that in
>the clipboard.
>I do this for our system, and the advantage is that you then allow pasting
>between different applications without requiring the same DLLs be shared.
>You also have to do this to drag-drop between applications, as this uses
>the same concepts as cut/paste.
>>
>I create my own serializable DragData Object that contains all the info I
>want to cut/paste, and this allows me to create a tidy 'packet' with all
>the associated metadata to reconstruct my objects when deserialized.
>>
>Cheers,
> Gadget
>>

Look here:
http://support.microsoft.com/kb/815813
and a whole thread on using strings (which is what you want)
http://www.thescripts.com/forum/thread175771.html

Remember, "Google is your friend".

Cheers,
Gadget

You will have to find what it is in your PlugInReport that is not
serializable. Simply setting the attribute is not enough.
Look at the details in the exception to find why it couldn't serialize it.

Cheers,
Gadget
The only option is to (if possible) create a special class that can store
all the parameters used to recreate an instance of your object.
I do this in one of our systems. We have tree structures you can drag
around, where nodes have references to items in lists.
I have a class with a tree node and another property into which I copy all
the lists the original tree would have referenced.

There is no easy workaround, we just have to work with what we have :)

Cheers,
Gadget
Nov 27 '06 #8

P: n/a
Thanks for the tip..
I will do that

regards
serge

"Gadget" wrote:
On Sun, 26 Nov 2006 23:53:01 -0800, calderara wrote:
Hi

I have still one question. I can control class reference or object of my own
to verify if there are serializable or not but if my library is using for
instance Crystal report reference object, I cannot change anything in that
library if it is not serializable...

What to do then ?

thnaks for help
regards

"Gadget" wrote:
On Fri, 24 Nov 2006 01:30:01 -0800, calderara wrote:

Thnaks for the links.
I have try to implement but when I create a new XMLSerializer object, then I
get an exception error saying "Error reflecting type PluginApp.PlugInReport"

here is my code

=====>
Dim s As System.Xml.Serialization.XmlSerializer = New
System.Xml.Serialization.XmlSerializer(GetType(Pl uginApp.PlugInReport))

Dim txtWriter As System.IO.TextWriter = New
System.IO.StreamWriter("f:\report.xml")

s.Serialize(txtWriter, CType(tvReport.SelectedNode.Tag,
PluginApp.PlugInReport))
I have set for the class that I want to serialize a <Serializableattributes
<<<<<=====
Any idea what is wrong ?
Do I miss something
regards
serge

"Gadget" wrote:

On Wed, 22 Nov 2006 23:37:01 -0800, calderara wrote:

Thnaks for your reply.
I have never done this, could you brifly explain me hoe to do it ?

regards
serge

"Gadget" wrote:

On Wed, 22 Nov 2006 06:11:02 -0800, serge calderara wrote:
>
>Dear all,
>>
>I have an treeview control with different node object, I would like to
>implement the Copy/Paste function of an object . For that I am using the
>folowing function to copy teh object to clipboard :
>>
>====>
>Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport)
>>
> ' Creates a new data format.
> m_ClipObjFormat = DataFormats.GetFormat("ReportFormat")
>>
> ' Creates a new object and store it in a DataObject using
>myFormat
> ' as the type of format.
>>
> Dim m_ReportObject As New DataObject(m_ClipObjFormat.Name, Obj)
>>
> ' Copies myObject into the clipboard.
> Clipboard.SetDataObject(m_ReportObject)
> End Sub
><=====
>>
>and the following object to get it back from clipboard
>>
>===>
>Private Sub PasteFromClipboard(ByVal ObjFormat As DataFormats.Format)
> ' Performs some processing steps.
> ' Retrieves the data from the clipboard.
> Dim m_RetrievedObject As IDataObject = Clipboard.GetDataObject()
>>
> ' Converts the IDataObject type to MyNewObject type.
> Dim myDereferencedObject As PluginApp.PlugInReport = _
> CType(m_RetrievedObject.GetData(ObjFormat.Name),
>PluginApp.PlugInReport)
>>
> ' Print the value of the Object in a textBox.
> m_PasteObject = myDereferencedObject
> End Sub
><=======
>>
>Problem I have with that is that when I read back the clipboad I get an
>empty object.
>Either the object has never been copied or not read back properly.
>>
>WHat is wrong ?
>>
>thanks for help
>serge
>
I have never been able to pass an object in the clipboard, and I think this
is by design. The only solution is to serialize the object and put that in
the clipboard.
I do this for our system, and the advantage is that you then allow pasting
between different applications without requiring the same DLLs be shared.
You also have to do this to drag-drop between applications, as this uses
the same concepts as cut/paste.
>
I create my own serializable DragData Object that contains all the info I
want to cut/paste, and this allows me to create a tidy 'packet' with all
the associated metadata to reconstruct my objects when deserialized.
>
Cheers,
Gadget
>

Look here:
http://support.microsoft.com/kb/815813
and a whole thread on using strings (which is what you want)
http://www.thescripts.com/forum/thread175771.html

Remember, "Google is your friend".

Cheers,
Gadget
You will have to find what it is in your PlugInReport that is not
serializable. Simply setting the attribute is not enough.
Look at the details in the exception to find why it couldn't serialize it.

Cheers,
Gadget

The only option is to (if possible) create a special class that can store
all the parameters used to recreate an instance of your object.
I do this in one of our systems. We have tree structures you can drag
around, where nodes have references to items in lists.
I have a class with a tree node and another property into which I copy all
the lists the original tree would have referenced.

There is no easy workaround, we just have to work with what we have :)

Cheers,
Gadget
Nov 27 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.