RichTextBox

S

Sanjay

hi all,
In VB6 we used to have a property called OLEObjects on RichTextBox.
I used it to make my richTextbox not accept OLE objects when user tries to
paste.
Code something like following:


If RichTextBox1.OLEObjects.count > 0 Then

If Len(Clipboard.getText) = 0 Then
' show Some message regarding OLE object pasting not supported
Else
RichTextBox1.SelRTF = Clipboard.getText
End If

RichTextBox1.OLEObjects.remove (0)

End If

I want to know how can it be achieved using .net RichTextBox.
plz help me on the same.
any help would be appreciated.

thanks

Sanjay Singh
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Sanjay,

Even though you can create your own OLE objects handler (overriding
RichTextBox's CreateRichEditOleCallback) I don't think this is what you want
to do. This would be the best solution, but windows forms doesn't provide
IRichEditOleCallback interface out of the box. So what I'd suggest is to
handle DragEnter as well as ctrl+v key combination and check the DataObject
in the clipboard ot that is dragged by the user for text inside. This is
pretty easy to do (see System.Windows.Forms.DataObject class in MSDN for
more info). So you can allow drop or paste at your discretion.
 
S

Sanjay

hi Stoitcho,

but I dont find any event like "DragEnter" . Do you mean "Enter" event or
what.
please clarify it.

thanks

sanjay

Stoitcho Goutsev (100) said:
Sanjay,

Even though you can create your own OLE objects handler (overriding
RichTextBox's CreateRichEditOleCallback) I don't think this is what you want
to do. This would be the best solution, but windows forms doesn't provide
IRichEditOleCallback interface out of the box. So what I'd suggest is to
handle DragEnter as well as ctrl+v key combination and check the DataObject
in the clipboard ot that is dragged by the user for text inside. This is
pretty easy to do (see System.Windows.Forms.DataObject class in MSDN for
more info). So you can allow drop or paste at your discretion.


--
Stoitcho Goutsev (100) [C# MVP]

Sanjay said:
hi all,
In VB6 we used to have a property called OLEObjects on RichTextBox.
I used it to make my richTextbox not accept OLE objects when user tries to
paste.
Code something like following:


If RichTextBox1.OLEObjects.count > 0 Then

If Len(Clipboard.getText) = 0 Then
' show Some message regarding OLE object pasting not supported
Else
RichTextBox1.SelRTF = Clipboard.getText
End If

RichTextBox1.OLEObjects.remove (0)

End If

I want to know how can it be achieved using .net RichTextBox.
plz help me on the same.
any help would be appreciated.

thanks

Sanjay Singh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top