473,327 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 3414
" 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Maya | last post by:
Hey, there! I'm new to vb.net and it seems I wouldn't be able to solve this without help. I have a pipe delimited file that has to be saved in txt format so it could be accepted by my DTS...
1
by: ksskumar | last post by:
Hi Friends, I am creating a application using C#. In that application I am using RichTextBox (System.Windows.Forms.RichTextBox). My query is how to create a file link in Rich text box. ...
3
by: sneffe | last post by:
Hi, Does anyone have an example of how to paste or inserting an image into a rtf file? I have tried the following but the image is represented as a lot of weird letters and numbers FileOpen(1,...
1
by: Grant Smith | last post by:
I've got an application that I can copy some text out of the RichTextBox control. I would like to keep the formatting so I'm able to copy it to the Clipboard with RTF formatting. I have no...
3
by: atif283 | last post by:
Hi I m worki on clip board m trying to copy RTF data(Text+Image) both txt and image on clip board its only pasting text On Excel not the image can any one help me in this regard I m using your...
1
by: Mayilsamy | last post by:
hai, hai i need some information about how to load the pdf file in richtextbox using vb.net.
9
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
I want to open a text file and format it into a specific line and then apply color to a specific location of the text and then display it in a RichTextBox after all of this is done. I can do all...
7
by: Tom | last post by:
Hi all, I am looking for a smart way to assure a file is indeed a text file within a C# method and not binary. For example: Will "thisMysteryFile.dat" be legible if opened in a RichTextBox...
3
by: Tom | last post by:
I don't want to re-invent the wheel and am looking for a simple implementation of a text viewer or RichTextBox in read only mode that allows rapid file positioning within large data files without...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.