Results 1 to 3 of 3

Thread: Rich Text Box blues [unresolved]

  1. #1

    Thread Starter
    Junior Member husain's Avatar
    Join Date
    Jul 2002
    Location
    United Arab Emirates
    Posts
    31

    Rich Text Box blues [unresolved]

    In my application, I have a rich text box that should only contain text (in rich text format with all those tabs and styles) but not images and other things. The only way things can be 'inserted' into this box is by pasting. So here's the sub that handles this:
    VB Code:
    1. Private Sub mnuSnippetBoxPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSnippetBoxPaste.Click
    2.   If SnippetBox.CanPaste([u]DataFormats.Rtf[/u]) Then
    3.     SnippetBox.Paste([u]DataFormats.Rtf[/u])
    4.   End If
    5. End Sub
    However, I get an error in both instances of DataFormats.Rtf (underlined above) that says:

    Value of type 'String' cannot be converted to 'System.Windows.Forms.DataFormats.Format'.

    Hope someone can tell me what I am doing wrong.
    Last edited by husain; Sep 16th, 2002 at 09:24 AM.

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    Try this:

    If RichTextBox1.CanPaste(DataFormats.GetFormat(DataFormats.Rtf)) Then
    RichTextBox1.Paste(DataFormats.GetFormat(DataFormats.Rtf))
    End If
    Wind and waves resolves all problems.

  3. #3

    Thread Starter
    Junior Member husain's Avatar
    Join Date
    Jul 2002
    Location
    United Arab Emirates
    Posts
    31
    That works! Thank you so much

    EDIT: Sorry about this but it still does not work. What I had done is just copied some text from the textbox itself and tested if it could paste. It did. Then I copied a bitmap and tried to paste. As expected, it did not paste it. However, when I tried to copy and paste some text from this forum (IE window), it would not paste.
    Last edited by husain; Sep 16th, 2002 at 09:23 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width