multiple formats on the clipboard

F

fred

I am trying to put a FileDrop format and a Text format dataobject onto the
clipboard so that they are both available.
I seem to be able to do one or the other but when I try to put both on only
the last entry is available on the clipboard.

Dim FileDataObject As New DataObject
Dim TextDataObject As New DataObject
Dim FileNames() As String = {myFileName}
FileDataObject.SetData(DataFormats.FileDrop, FileNames)
Clipboard.SetDataObject(FileDataObject, True)
TextDataObject.SetData(DataFormats.Text, myFileName)
Clipboard.SetDataObject(TextDataObject, True)

If I run the above statements only the Text format data is available on the
clipboard. If I comment out the last line then the File Format data is
available.
Since they are different formats shouldn't they both be available at the
same time.
What am I doing wrong. How do I get both formats onto the clipboard.

Thanks,
Fred
 
A

Armin Zingler

fred said:
I am trying to put a FileDrop format and a Text format dataobject
onto the clipboard so that they are both available.
I seem to be able to do one or the other but when I try to put both
on only the last entry is available on the clipboard.

Dim FileDataObject As New DataObject
Dim TextDataObject As New DataObject
Dim FileNames() As String = {myFileName}
FileDataObject.SetData(DataFormats.FileDrop, FileNames)
Clipboard.SetDataObject(FileDataObject, True)
TextDataObject.SetData(DataFormats.Text, myFileName)
Clipboard.SetDataObject(TextDataObject, True)

If I run the above statements only the Text format data is available
on the clipboard. If I comment out the last line then the File Format
data is available.
Since they are different formats shouldn't they both be available at
the same time.
What am I doing wrong. How do I get both formats onto the
clipboard.

You can only put /one/ object in the clipboard. The object might be returned
in different /formats/:

Const myFileName As String = "filename"

Dim FileDataObject As New DataObject
Dim FileNames() As String = {myFileName}

FileDataObject.SetData(DataFormats.FileDrop, FileNames)
FileDataObject.SetData(DataFormats.Text, myFileName)
Clipboard.SetDataObject(FileDataObject, True)
MsgBox(String.Join(vbCrLf, Clipboard.GetDataObject.GetFormats))



--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top