471,594 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

Copy and Pasting RTF to non RTF supported program

I've got an application that I can copy some text out of the
RichTextBox control. I would like to keep the formatting so I'm able
to copy it to the Clipboard with RTF formatting. I have no trouble
pasting the formatted text into wordpad (which supports RTF formatting)
but it won't paste into notepad (no RTF support). I know that if I
copy something in wordpad with RTF formatting and then paste it into
notepad the text will paste. What am I missing that will let me paste
RTF formatted text into an application that doesn't support RTF
formatting?

Here's the code I have to copy:
Clipboard.SetText(rtxtOutput.SelectedRtf,
TextDataFormat.Rtf);

I've also tried
String spareData = rtxtOutput.SelectedRtf;

DataObject newData = new DataObject(DataFormats.Rtf,
spareData);

Clipboard.SetDataObject(newData, true);
But neither will allow me to paste RTF formatted text into a non-RTF
supported application.

Anyone able to help me?

Jan 26 '07 #1
1 3663
On Fri, 26 Jan 2007 11:47:56 -0800, Grant Smith <gr********@gmail.com>
wrote:
[...] I know that if I
copy something in wordpad with RTF formatting and then paste it into
notepad the text will paste. What am I missing that will let me paste
RTF formatted text into an application that doesn't support RTF
formatting?
Typically, the solution to this is that you have to copy both RTF and
plain text data to the clipboard. Generally speaking, you put each data
format suitable for the data being copied on the clipboard. Then
applications pasting the data choose their preferred format, falling back
on other formats as necessary.

The documentation for .NET support of the clipboard hints at an ability to
do conversions on the fly from clipboard data but a) I have not found the
..NET Clipboard class to always work as advertised, and b) I think this
would only help when pasting into a .NET application. If you want to
support plain text pasting into other applications, you need to include
that format among the data formats you put on the clipboard.

Pete
Jan 26 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by mescaline | last post: by
1 post views Thread by Bob T Bunny | last post: by
4 posts views Thread by Legendary Pansy | last post: by
7 posts views Thread by lgbjr | last post: by
17 posts views Thread by Steve | last post: by
8 posts views Thread by Wolfgang Draxinger | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.