views:

655

answers:

3

Hi everybody, I have a problem when pasting ms word content into richtextbox.

when I copy content of word document and paste it into richtextbox which is in a windows application written in C#. the links are shown like that ;

This is test.. Go to Google. <http://www.google.com&gt;
Mail : Project <mailto:[email protected]>

The issue can also be created by loading in an saved RTF document from word.

How can I correct this, please help..

thanks in advance.

+4  A: 

The issue here is that you're not actually copying RTF into the clipboard from Word. Well, kind of, but not the same RTF that would display just the formatted text and have a hyperlink behind it. You'd have to handle the paste event and do your own parsing and reformatting to achieve that.

Otaku
+1  A: 

Some richtextbox editors have a "Paste from Word" feature. You can paste it in a simple textbox and start re-formatting based on the rich text editor you're using.

Tudorizer
+1  A: 

This behavior has nothing to do with Word. In fact even though the RTF produced in the Clipboard by MS Word is slightly different from that of OpenOffice the results are identical. See screenshot below where the top two links are from MS Word and the rest from OOo 3.2.

alt text.

It seems to be a peculiarity in the drawing of hyperlinks in the Winforms RichTextBox. I don't see a quick workaround to change this behavior though.

renick