in Immeidate window it works but not on class- RTF-clipborad

Hi All,

I've a very simple problem. When i convert simple text into RTF in a class it doesnt work but whne I see the result in immeidate window I'm able to see the actual result. Why is this difference Please see the below code and its very simple and starightforward but I'm struggling to findout the root cause.

Dim objData As New DataObject(strText)

Clipboard.SetDataObject(objData)

Dim reverdata As New DataObject

reverdata = Clipboard.GetDataObject()

'now get the new object

If Not reverdata Is Nothing Then

strRichText = reverdata.GetData("Rich Text Format", True)

End If

when i see the value of reverdata.GetData("Rich Text Format", True) in immediate window I'm able to see RTF string but when I run the program I get nothing in strRichText variable.

Any thoughts I'm using 1.1 framework.

Cheers,

Rama




Answer this question

in Immeidate window it works but not on class- RTF-clipborad

  • GroZZleR

    Hi All,

    Can anyone help me



  • Jignesh Vyas

    Hi nobugz,

    Thanks a lot. its working fine.

    Cheers,

    Rama



  • grhomm

    It's pretty amazing you can see RTF in the Immediate window, the clipboard is not automagically going to convert plain text to RTF. Another way to do it is to use a RichTextBox to do the conversion for you. For example:

    public static string ConvertText2Rtf(string txt) {
    using (RichTextBox rtb = new RichTextBox()) {
    rtb.Text = txt;
    return rtb.Rtf;
    }
    }



  • in Immeidate window it works but not on class- RTF-clipborad