468,121 Members | 1,420 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,121 developers. It's quick & easy.

The Copy Buffer & RichTextBox

Tom
When I use ctrl-c to copy and ctrl-v to paste from a RichTextBox into
NotePad ... I get nice ASCII text with the proper returns. Everything
looks good. When I paste into WordPad ... I get the RichText font
attributes and paragraph formatting as seen in the RichTextBox. Again,
everything looks good.

Trying to do the above programmatically is causing me problems. The
text is there, but in NotePad the returns are absent and the square
boxes (formatting stuff) are visible. In WordPad, the text is there
with returns ... but the font color attributes and paragraph spacing
is absent.

I've read the online doco about multiformatting the copy buffer and
found this very interesting. I was wondering how the ctrl-c had worked
its magic between NotePad and WordPad. However, I have yet to
duplicate the RichTextBox copy command programmatically. Below are
some of the commands I have tried >>

// BeginBlock & EndBlock are saved index values.

DataObject data = new DataObject();
textBox.Select((int)BeginBlock, (int)(EndBlock - BeginBlock));
data.SetData(DataFormats.Text, true, textBox.SelectedText);
data.SetData(DataFormats.Rtf, false, textBox.SelectedText);
Clipboard.SetDataObject(data);

-------------

I've also tried UnicodeText and StringFormat formats with the bool
conversion set to true and false.

Any clues to how I can programmatically duplicate the RichTextBox's
built-in ctrl-c functionality?

Thanks for any help.

-- Tom
Feb 26 '08 #1
0 1820

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Hariharan Subramony | last post: by
4 posts views Thread by Legendary Pansy | last post: by
2 posts views Thread by Curious | last post: by
19 posts views Thread by ivan.leben | last post: by
17 posts views Thread by AWW | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.