473,696 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Copy/Paste to clipboard ??

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.PlugI nReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.Get Format("ReportF ormat")

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

Dim m_ReportObject As New DataObject(m_Cl ipObjFormat.Nam e, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDa taObject(m_Repo rtObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipbo ard(ByVal ObjFormat As DataFormats.For mat)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObje ct As IDataObject = Clipboard.GetDa taObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedO bject As PluginApp.PlugI nReport = _
CType(m_Retriev edObject.GetDat a(ObjFormat.Nam e),
PluginApp.PlugI nReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedO bject
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
8 2611
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.PlugI nReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.Get Format("ReportF ormat")

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

Dim m_ReportObject As New DataObject(m_Cl ipObjFormat.Nam e, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDa taObject(m_Repo rtObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipbo ard(ByVal ObjFormat As DataFormats.For mat)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObje ct As IDataObject = Clipboard.GetDa taObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedO bject As PluginApp.PlugI nReport = _
CType(m_Retriev edObject.GetDat a(ObjFormat.Nam e),
PluginApp.PlugI nReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedO bject
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
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.PlugI nReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.Get Format("ReportF ormat")

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

Dim m_ReportObject As New DataObject(m_Cl ipObjFormat.Nam e, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDa taObject(m_Repo rtObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipbo ard(ByVal ObjFormat As DataFormats.For mat)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObje ct As IDataObject = Clipboard.GetDa taObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedO bject As PluginApp.PlugI nReport = _
CType(m_Retriev edObject.GetDat a(ObjFormat.Nam e),
PluginApp.PlugI nReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedO bject
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
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.PlugI nReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.Get Format("ReportF ormat")

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

Dim m_ReportObject As New DataObject(m_Cl ipObjFormat.Nam e, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDa taObject(m_Repo rtObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipbo ard(ByVal ObjFormat As DataFormats.For mat)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObje ct As IDataObject = Clipboard.GetDa taObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedO bject As PluginApp.PlugI nReport = _
CType(m_Retriev edObject.GetDat a(ObjFormat.Nam e),
PluginApp.Plu gInReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedO bject
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
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.PlugI nReport"

here is my code

=====>
Dim s As System.Xml.Seri alization.XmlSe rializer = New
System.Xml.Seri alization.XmlSe rializer(GetTyp e(PluginApp.Plu gInReport))

Dim txtWriter As System.IO.TextW riter = New
System.IO.Strea mWriter("f:\rep ort.xml")

s.Serialize(txt Writer, CType(tvReport. SelectedNode.Ta g,
PluginApp.PlugI nReport))
I have set for the class that I want to serialize a <Serializableat tributes
<<<<<=====
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.PlugI nReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.Get Format("ReportF ormat")

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

Dim m_ReportObject As New DataObject(m_Cl ipObjFormat.Nam e, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDa taObject(m_Repo rtObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipbo ard(ByVal ObjFormat As DataFormats.For mat)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObje ct As IDataObject = Clipboard.GetDa taObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedO bject As PluginApp.PlugI nReport = _
CType(m_Retriev edObject.GetDat a(ObjFormat.Nam e),
PluginApp.Plug InReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedO bject
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
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.PlugI nReport"

here is my code

=====>
Dim s As System.Xml.Seri alization.XmlSe rializer = New
System.Xml.Seri alization.XmlSe rializer(GetTyp e(PluginApp.Plu gInReport))

Dim txtWriter As System.IO.TextW riter = New
System.IO.Strea mWriter("f:\rep ort.xml")

s.Serialize(txt Writer, CType(tvReport. SelectedNode.Ta g,
PluginApp.PlugI nReport))
I have set for the class that I want to serialize a <Serializableat tributes
<<<<<=====
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.PlugI nReport)
>
' Creates a new data format.
m_ClipObjFormat = DataFormats.Get Format("ReportF ormat")
>
' Creates a new object and store it in a DataObject using
myFormat
' as the type of format.
>
Dim m_ReportObject As New DataObject(m_Cl ipObjFormat.Nam e, Obj)
>
' Copies myObject into the clipboard.
Clipboard.SetDa taObject(m_Repo rtObject)
End Sub
<=====
>
and the following object to get it back from clipboard
>
===>
Private Sub PasteFromClipbo ard(ByVal ObjFormat As DataFormats.For mat)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObje ct As IDataObject = Clipboard.GetDa taObject()
>
' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedO bject As PluginApp.PlugI nReport = _
CType(m_Retriev edObject.GetDat a(ObjFormat.Nam e),
PluginApp.P lugInReport)
>
' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedO bject
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
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.PlugI nReport"

here is my code

=====>
Dim s As System.Xml.Seri alization.XmlSe rializer = New
System.Xml.Seri alization.XmlSe rializer(GetTyp e(PluginApp.Plu gInReport))

Dim txtWriter As System.IO.TextW riter = New
System.IO.Strea mWriter("f:\rep ort.xml")

s.Serialize(txt Writer, CType(tvReport. SelectedNode.Ta g,
PluginApp.PlugI nReport))
I have set for the class that I want to serialize a <Serializableat tributes
<<<<<=====
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.PlugI nReport)

' Creates a new data format.
m_ClipObjFormat = DataFormats.Get Format("ReportF ormat")

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

Dim m_ReportObject As New DataObject(m_Cl ipObjFormat.Nam e, Obj)

' Copies myObject into the clipboard.
Clipboard.SetDa taObject(m_Repo rtObject)
End Sub
<=====

and the following object to get it back from clipboard

===>
Private Sub PasteFromClipbo ard(ByVal ObjFormat As DataFormats.For mat)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim m_RetrievedObje ct As IDataObject = Clipboard.GetDa taObject()

' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedO bject As PluginApp.PlugI nReport = _
CType(m_Retriev edObject.GetDat a(ObjFormat.Nam e),
PluginApp.Pl ugInReport)

' Print the value of the Object in a textBox.
m_PasteObject = myDereferencedO bject
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
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.PlugI nReport"

here is my code

=====>
Dim s As System.Xml.Seri alization.XmlSe rializer = New
System.Xml.Se rialization.Xml Serializer(GetT ype(PluginApp.P lugInReport))

Dim txtWriter As System.IO.TextW riter = New
System.IO.Str eamWriter("f:\r eport.xml")

s.Serialize(t xtWriter, CType(tvReport. SelectedNode.Ta g,
PluginApp.Plu gInReport))
I have set for the class that I want to serialize a <Serializableat tributes
<<<<<=====
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
>>impleme nt the Copy/Paste function of an object . For that I am using the
>>folowin g function to copy teh object to clipboard :
>>>
>>====>
>>Private Sub CopyToClipboard (ByVal Obj As PluginApp.PlugI nReport)
>>>
>> ' Creates a new data format.
>> m_ClipObjFormat = DataFormats.Get Format("ReportF ormat")
>>>
>> ' Creates a new object and store it in a DataObject using
>>myForma t
>> ' as the type of format.
>>>
>> Dim m_ReportObject As New DataObject(m_Cl ipObjFormat.Nam e, Obj)
>>>
>> ' Copies myObject into the clipboard.
>> Clipboard.SetDa taObject(m_Repo rtObject)
>> End Sub
>><=====
>>>
>>and the following object to get it back from clipboard
>>>
>>===>
>>Private Sub PasteFromClipbo ard(ByVal ObjFormat As DataFormats.For mat)
>> ' Performs some processing steps.
>> ' Retrieves the data from the clipboard.
>> Dim m_RetrievedObje ct As IDataObject = Clipboard.GetDa taObject()
>>>
>> ' Converts the IDataObject type to MyNewObject type.
>> Dim myDereferencedO bject As PluginApp.PlugI nReport = _
>> CType(m_Retriev edObject.GetDat a(ObjFormat.Nam e),
>>PluginApp .PlugInReport)
>>>
>> ' Print the value of the Object in a textBox.
>> m_PasteObject = myDereferencedO bject
>> 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
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.PlugI nReport"

here is my code

=====>
Dim s As System.Xml.Seri alization.XmlSe rializer = New
System.Xml.Ser ialization.XmlS erializer(GetTy pe(PluginApp.Pl ugInReport))

Dim txtWriter As System.IO.TextW riter = New
System.IO.Stre amWriter("f:\re port.xml")

s.Serialize(tx tWriter, CType(tvReport. SelectedNode.Ta g,
PluginApp.Plug InReport))
I have set for the class that I want to serialize a <Serializableat tributes
<<<<<=====
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
>implemen t 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.PlugI nReport)
>>
> ' Creates a new data format.
> m_ClipObjFormat = DataFormats.Get Format("ReportF ormat")
>>
> ' Creates a new object and store it in a DataObject using
>myFormat
> ' as the type of format.
>>
> Dim m_ReportObject As New DataObject(m_Cl ipObjFormat.Nam e, Obj)
>>
> ' Copies myObject into the clipboard.
> Clipboard.SetDa taObject(m_Repo rtObject)
> End Sub
><=====
>>
>and the following object to get it back from clipboard
>>
>===>
>Private Sub PasteFromClipbo ard(ByVal ObjFormat As DataFormats.For mat)
> ' Performs some processing steps.
> ' Retrieves the data from the clipboard.
> Dim m_RetrievedObje ct As IDataObject = Clipboard.GetDa taObject()
>>
> ' Converts the IDataObject type to MyNewObject type.
> Dim myDereferencedO bject As PluginApp.PlugI nReport = _
> CType(m_Retriev edObject.GetDat a(ObjFormat.Nam e),
>PluginApp. PlugInReport)
>>
> ' Print the value of the Object in a textBox.
> m_PasteObject = myDereferencedO bject
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4334
by: tabonni | last post by:
Hello All I am creating an ASP page. There are a list of filename and checkbox next to it. When user checked all the documents they want and click ADD TO CLIPBOARD button. All filepaths will be copied into clipboard and then they can right-click -> paste into MS Outlook as attachments. How can I use clipboardData.setData function to do that? I saw a lot of examples they are just copy and paste text.
3
43362
by: Tor Inge Rislaa | last post by:
Copy, Cut and Paste How to code the Copy, Cut and Paste functionality in VB.NET. In VB 6.0 I used the following code: 'For Copy Clipboard.Clear Clipboard.SetText ActiveForm.ActiveControl.SelText, vbCFText
5
21021
by: DraguVaso | last post by:
Hi, I'm looking for a way to Copy and Paste Files to the clipboard. I found a lot of articles to copy pieces of text and bitmaps etc, but nog whole files. Whay I need is like you have in windows explorer: when you do a right-click on a file and choose Copy, and than paste it somewhere in my application and vice versa.
2
2682
by: Keith | last post by:
I'm trying to come up with a way to create a contextmenu that will do all the "standard" functions (cut, copy, paste, undo, etc). There seems to be a lot of information out there - but nothing seems to work for me. A few people refer to txt.copy() txt.paste(), etc. I'm not sure if those are old functions, but they do not work for me. I've tried textbox1.selectall() - that works in selecting
7
11624
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
6
9649
by: Ben R. | last post by:
Hi, I've got a vb.net winforms app. Out of the box, I can use Ctrl X, C and V as expected in controls like textboxes. I've got a menustrip, and if I click the link "Add standard items" which adds Cut copy and paste commands, this functionality no longer works. It seems now I need to implement handlers for these functions. I tried to do so, but say the paste handler, I need to call paste on a specific control and that isn't necessarily...
9
4813
by: Alan T | last post by:
Any source code example I can use to save the clipboard content to an object, then I will do a copy and paste, finally put back the 'saved' clipboard content back to clipboard ?
17
5121
by: Steve | last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user clicks on a toolbar button, the cut/copy/paste will work with whatever textbox the cursor is current located in (I have about 20 textboxes on the form). Also to ensure that the button can't get used if the cursor isn't in a textbox field. And to ensure the contents of the clipboard are "text" contents that have been cut/copied from one of the textboxes on the form. ...
8
15436
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
0
8594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9005
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4352
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3027
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2310
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.