473,837 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inserting images in richtextbox

Hi!
I have an imageList and a richtextbox in a C# form. I want to insert
image from imageList into a richtextbox.

I have found the following code on net but it does'nt work.

InsertImage(Emo tionsImageList. Images[0]);

public void InsertImage(Ima ge pic)
{
//string lstrFile = fileDialog.File Name;
Bitmap myBitmap = new Bitmap(pic);
// Copy the bitmap to the clipboard.
Clipboard.SetDa taObject(myBitm ap);
// Get the format for the object type.
DataFormats.For mat myFormat = DataFormats.Get Format
(DataFormats.Bi tmap);
// After verifying that the data can be pasted, paste
rtxtAllMessages .ReadOnly = false;
if(rtxtAllMessa ges.CanPaste(my Format))
{
rtxtAllMessages .Paste(myFormat );
}
else
{
MessageBox.Show ("The data format that you attempted site" +
" is not supported by this control.");
}
rtxtAllMessages .ReadOnly = true;
}
Can any one help me.

Dec 8 '06 #1
1 11028
Hi,

I'm fairly certain there is a way by setting the Rtf property itself but I
don't remember how exactly - something like \pict is the RTF you'd need.

Anyway, if you aren't tied down to using RTF (if you're writing your own
chat client, for example) then you might want to try hosting a WebBrowser
control (2.0 framework) in design-mode instead. If you know HTML then
you'll have a much easier time using the WebBrowser control, and it's much
more flexible (e.g., javascript, edit designers).

"WebBrowser Control (Windows Forms)"
http://msdn2.microsoft.com/en-us/library/2te2y1x6.aspx

"DHTML document.design Mode property"
http://msdn2.microsoft.com/en-us/library/ms533720.aspx

In case you really do need RTF here's a short article with some links to RTF
specifications:

"Rich Text Format"
http://en.wikipedia.org/wiki/Rich_Text_Format

If you'd prefer to just fix the code that you've posted then you're going to
have to supply more information, such as the error message, at least, and
either the stack trace or the line at which the exception is being thrown.

If you're not getting an error, then what unexpected behavior have you
observed from that code?

--
Dave Sexton

<fa************ *@gmail.comwrot e in message
news:11******** *************@8 0g2000cwy.googl egroups.com...
Hi!
I have an imageList and a richtextbox in a C# form. I want to insert
image from imageList into a richtextbox.

I have found the following code on net but it does'nt work.

InsertImage(Emo tionsImageList. Images[0]);

public void InsertImage(Ima ge pic)
{
//string lstrFile = fileDialog.File Name;
Bitmap myBitmap = new Bitmap(pic);
// Copy the bitmap to the clipboard.
Clipboard.SetDa taObject(myBitm ap);
// Get the format for the object type.
DataFormats.For mat myFormat = DataFormats.Get Format
(DataFormats.Bi tmap);
// After verifying that the data can be pasted, paste
rtxtAllMessages .ReadOnly = false;
if(rtxtAllMessa ges.CanPaste(my Format))
{
rtxtAllMessages .Paste(myFormat );
}
else
{
MessageBox.Show ("The data format that you attempted site" +
" is not supported by this control.");
}
rtxtAllMessages .ReadOnly = true;
}
Can any one help me.

Dec 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5878
by: Mat | last post by:
Hi, I have a system that uploads images as BLOBs in a database. I also have a function that I use to resize uploaded images before saving as files. I would like to combine these two by resising the images before inserting them as BLOBs. My problem is that (apart from being new to file stuff) my resize function returns a Resource ID which of course is not the same as the file handler that was passed to it, it's a reference to an image...
2
8915
by: Hendrik | last post by:
Hi I have searched extensively for help on inserting text at the position of the mouse pointer in a text box as the final step of drag and drop process What I have come with is listed below - the problem is that the SendMessage function doesn't seem to perform the expected operation of moving the caret to position in the textbox where the mouse is pointing to. (can be text or richtext box either is good - sample code is based of attemp...
5
10544
by: Alvo von Cossel I | last post by:
hi, i have a word processor with a richtextbox in the center of the screen. if you paste an image into the richtextbox, it will appear. however, with my openfiledialog, only some text will appear (the url of the image). here is my code: if(openfiledialog1.showdialog()==dIALOGRESULT.OK) { RICHTEXTBOX1.TEXT=RICHTEXTBOX1.TEXT+OPENFILEDIALOG1.FILENAME;
1
5333
by: gabe | last post by:
I am looking for a way to mimic some of the functionality of a web page without writing html (or I am looking to someone to point out something really obvious that I am over looking) Currently I read out some data into a dataset then appending it to a richtextbox. So far so good. Some of the fields that I append are paths to documents. I would like to be able to click on the paths (like a hyperlink) I am able to create a linklabel at...
2
1687
by: Jim | last post by:
Could someone please point me to some sample source code for including images within a Richtextbox in VB.NET, without using the clipboard ? Thanks in advance! Jim
2
6075
by: Clark Stevens | last post by:
Hi. This should be so easy, but I don't get it. Let say I have RichTextbox1 and I want to insert some text at the current insertion point, or at the beginning of selected text (if there is any). How is this done? Also, how do I delete the current selection? Thanks.
0
2949
by: Cub71 | last post by:
I have a richtextbox that I would like to fill with some lines, and they have to be aligned with tab stops. I think I have set the tab stops, but I can't find any info on how to tell the richtextbox to jump to the next tab. First, is this correct?: richTextBox1.SelectAll(); int tabStops = {4,8,12,16,20, 24}; richTextBox1.SelectionTabs = tabStops;
0
1526
by: ajithmanmadhan | last post by:
hi pls help me out in inserting text into a richtextbox. the situation is like this:: i want to insert a string say "hello" at a particular location in the rich textbox. The particular location is given in the form of X and Y coordinates. eg:: PutString("hello",10,20) i write a function that passes the string and x,y coordinates. is that possible?? x,y coordinates will represent the location of the string in richtextbox.
1
3025
by: shakti s | last post by:
hi, My aplologies if this is really a silly question. I am trying to read contents like images and tables from one rich text box and paste it into another RTF control(i.e. another Richtextbox). when i am doing this...the rtf encoding is getting displayed in the destination RichTextBox. i think i am missing out something there.
0
9843
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10875
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10566
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10272
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7806
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7001
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5669
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.