473,396 Members | 1,861 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,396 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 3420
" 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.