|
-
Sep 15th, 2002, 08:59 AM
#1
Thread Starter
Junior Member
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:
Private Sub mnuSnippetBoxPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSnippetBoxPaste.Click
If SnippetBox.CanPaste([u]DataFormats.Rtf[/u]) Then
SnippetBox.Paste([u]DataFormats.Rtf[/u])
End If
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.
-
Sep 16th, 2002, 04:03 AM
#2
Addicted Member
Try this:
If RichTextBox1.CanPaste(DataFormats.GetFormat(DataFormats.Rtf)) Then
RichTextBox1.Paste(DataFormats.GetFormat(DataFormats.Rtf))
End If
Wind and waves resolves all problems.
-
Sep 16th, 2002, 09:16 AM
#3
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|