Clipboard support for multiple copies

Is there a way to duplicate the Office clipboard functionality in VB.Net? I would like to open a file, select some things and copy them to the clipboard, then select and copy some more things to the clipboard, then paste based on an index.

 

 

 

Posted by: Michael Frayser
Post date: 10/19/2005 5:01:42 AM

2 REPLIES

RE: Clipboard support for multiple copies

Michael,

 

Below is how I'd do it. You'd have to code selecting an object then copying it to the clipboard. After the object was on the clipboard, you get retrieve it using the GetDataObject() method and add it to an ArrayList. When you were ready to paste, you can loop through the list and call SetDataObject(). HTH

 

 

Public Class Form1

Inherits System.Windows.Forms.Form

 

Private listObjects As System.Collections.ArrayList

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim objDataObject As IDataObject

 

listObjects = New System.Collections.ArrayList

End Sub

 

Private Sub CopyToOfficeClipboard()

listObjects.Add(Clipboard.GetDataObject())

End Sub

 

Private Sub PasteFromOfficeClipboard()

Dim objDataObject As IDataObject

Dim i As Integer

 

For i = 0 To listObjects.Count

Clipboard.SetDataObject(listObjects.Item(i))

' Now execute paste

Next

End Sub

End Class

 

 

Posted by: Jason Newell
Post date: 10/19/2005 5:40:52 AM

RE: Clipboard support for multiple copies

Thanks for the tip!

 

Posted by: Michael Frayser
Post date: 10/25/2005 12:54:26 AM