inserting images into richtextbox

G

Guest

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;
}

WHAT AM I DOING (sorry about the sudden caps lock!) wrong?
 
O

Octavio Hernandez

Alvo,

You're adding to the textbox the name of the file (url), not the contents!
You should use the Image.FromFile() or similar to generate an image from the
(contents of the) file, and then paste it into the textbox.

Regards - Octavio
 
G

Guest

hi,

my code now is

if(openfiledialog.showdialog()==dialogresult.ok)
{
richtextbox1.text=richtextbox1.text+image.fromfile(openfiledialog1.filename);
}

this still diaplays some text like system.drawing.bitmap. what am i doing
wrong now? image.filename() doesnt work on its own, it needs some arguments
(openfiledialog.filename). i cant picture what i'm doing wrong

thanks in advance
 
R

Rachel Suddeth

The "Text" is type string. I am surprised if the code below even compiles,
but if it does, it will most likely be using the Bitmap's ToString()
implementation, which is just going to return the type name. Check this link
for a sample of how to really insert a non-text object:
http://www.developerfusion.co.uk/show/16/8/

-Rachel
 
R

Rachel Suddeth

Nevermind the article - was not about .NET control, apparently. Looks like
it's not so easy <sigh> seems like everything with this control is that way.
 

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