The Copy Buffer & RichTextBox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom

    #1

    The Copy Buffer & RichTextBox

    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 programmaticall y 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 programmaticall y. 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(Da taFormats.Text, true, textBox.Selecte dText);
    data.SetData(Da taFormats.Rtf, false, textBox.Selecte dText);
    Clipboard.SetDa taObject(data);

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

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

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

    Thanks for any help.

    -- Tom
Working...