469,945 Members | 1,813 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

Pasting a BMP file into RichTextBox

I've seen code that copies a bmp file into a RichTextBox by first putting it
into the clipboard and then using Paste to get it into the RichtextBox. This
destroys the clipboard contents.

Is there an easy way to save the clipboard contents and then restore it?
Thanks
Nov 21 '05 #1
6 3239
" Just Me" <gr****@a-znet.com> schrieb:
I've seen code that copies a bmp file into a RichTextBox by first putting
it into the clipboard and then using Paste to get it into the RichtextBox.
This destroys the clipboard contents.


You may want to use this extended richtextbox control instead of the
standard richtextbox:

Insert Plain Text and Images into RichTextBox at Runtime
<URL:http://www.codeproject.com/cs/miscctrl/CsExRichTextBox.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Thanks but I'd rather not use that control.

As to my question, Isn't there an easy way to grab the clipboard contents
and later restore them?

Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
" Just Me" <gr****@a-znet.com> schrieb:
I've seen code that copies a bmp file into a RichTextBox by first putting
it into the clipboard and then using Paste to get it into the
RichtextBox. This destroys the clipboard contents.


You may want to use this extended richtextbox control instead of the
standard richtextbox:

Insert Plain Text and Images into RichTextBox at Runtime
<URL:http://www.codeproject.com/cs/miscctrl/CsExRichTextBox.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
" Just Me" <gr****@a-znet.com> schrieb:
As to my question, Isn't there an easy way to grab the clipboard contents
and later restore them?


Untested:

\\\
Dim ClipboardContent As Image = _
DirectCast( _
Clipboard.GetDataObject().GetData(DataFormats.Bitm ap), _
Image _
)
Dim img As Image = Image.FromFile("C:\WINDOWS\Angler.bmp")
Clipboard.SetDataObject(img)
RichTextBox1.Paste()
If Not ClipboardContent Is Nothing Then
Clipboard.SetDataObject(ClipboardContent, True)
ClipboardContent.Dispose()
End If
img.Dispose()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
I'll test it

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ug**************@TK2MSFTNGP15.phx.gbl...
" Just Me" <gr****@a-znet.com> schrieb:
As to my question, Isn't there an easy way to grab the clipboard contents
and later restore them?


Untested:

\\\
Dim ClipboardContent As Image = _
DirectCast( _
Clipboard.GetDataObject().GetData(DataFormats.Bitm ap), _
Image _
)
Dim img As Image = Image.FromFile("C:\WINDOWS\Angler.bmp")
Clipboard.SetDataObject(img)
RichTextBox1.Paste()
If Not ClipboardContent Is Nothing Then
Clipboard.SetDataObject(ClipboardContent, True)
ClipboardContent.Dispose()
End If
img.Dispose()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
me 2.. i will not used third party.

Just Me wrote:
Thanks but I'd rather not use that control.

As to my question, Isn't there an easy way to grab the clipboard contents
and later restore them?

Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

" Just Me" <gr****@a-znet.com> schrieb:

I've seen code that copies a bmp file into a RichTextBox by first putting
it into the clipboard and then using Paste to get it into the
RichtextBox. This destroys the clipboard contents.

You may want to use this extended richtextbox control instead of the
standard richtextbox:

Insert Plain Text and Images into RichTextBox at Runtime
<URL:http://www.codeproject.com/cs/miscctrl/CsExRichTextBox.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



Nov 21 '05 #6

"Supra" <su*****@rogers.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
me 2.. i will not used third party.

Thanks

Just Me wrote:

Thanks but I'd rather not use that control.

As to my question, Isn't there an easy way to grab the clipboard contents
and later restore them?

Thanks
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

" Just Me" <gr****@a-znet.com> schrieb:

I've seen code that copies a bmp file into a RichTextBox by first putting
it into the clipboard and then using Paste to get it into the
RichtextBox. This destroys the clipboard contents.

You may want to use this extended richtextbox control instead of the
standard richtextbox:

Insert Plain Text and Images into RichTextBox at Runtime
<URL:http://www.codeproject.com/cs/miscctrl/CsExRichTextBox.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by ksskumar | last post: by
3 posts views Thread by sneffe | last post: by
1 post views Thread by Grant Smith | last post: by
9 posts views Thread by =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post: by
7 posts views Thread by Tom | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.