By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,171 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,171 IT Pros & Developers. It's quick & easy.

Copy and Pasting RTF to non RTF supported program

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.