I am simply trying to write CSV data to the the clipboard. The code
below is not working. Any suggestions?
Dim data As New DataObject
Dim ms As New MemoryStream
Dim sw As New StreamWriter(ms)
sw.Write("Tom")
sw.Write(",")
sw.Write("Jones")
sw.Write(",")
sw.Write(100)
sw.WriteLine()
sw.Write(Chr(0))
sw.Close()
data.SetData(DataFormats.CommaSeparatedValue, ms)
Clipboard.SetDataObject(data, False)
ms.Close()
THANKS
Bob
This seemed to work for me.
Dim data As New DataObject
Dim sb As New System.Text.StringBuilder
sb.Append("Tom")
sb.Append(",")
sb.Append("Jones")
sb.Append(",")
sb.Append("100")
sb.Append(Environment.NewLine)
'sb.Append(Chr(0))
data.SetData(DataFormats.CommaSeparatedValue, sb.ToString())
Clipboard.SetDataObject(data)
To retrieve it:
Me.TextBox1.Text =
Clipboard.GetDataObject().GetData(DataFormats.CommaSeparatedValue).ToString(
)
=================================
Clay Burch, .NET MVP
Visit www.syncfusion.com for the coolest tools
> I am simply trying to write CSV data to the the clipboard. The code
> below is not working. Any suggestions?
[quoted text clipped - 19 lines]
> THANKS
> Bob
Bob - 23 Jul 2004 18:14 GMT
Clay thanks for the help. I tried your code and my clipboard viewer
displays the CSV data just fine. However, I can not past this into
Excel, Word, or Notepad. I am using CSV to alow some records to be
copied to other applications. Any further suggestions?
Again thanks,
Bob
ClayB [Syncfusion] - 24 Jul 2004 01:09 GMT
Here is a FAQ that has code snippets that use CSV clipboard formats.
How do I use the CSV clipboard format supported by Excel?
Check it out at:
http://www.syncfusion.com/faq/winforms/search/899.asp
=============================================
Clay Burch, .NET MVP
Syncfusion, Inc.
visit http://www.syncfusion.com for .NET Essentials
> Clay thanks for the help. I tried your code and my clipboard viewer
> displays the CSV data just fine. However, I can not past this into
[quoted text clipped - 3 lines]
> Again thanks,
> Bob