471,071 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 1926

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
reply views Thread by leo001 | 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.