By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

inserting images into richtextbox

P: n/a
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+OPENFILEDIALOG 1.FILENAME;
}

WHAT AM I DOING (sorry about the sudden caps lock!) wrong?
--
Alvo von Cossel I of Germany
Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

"Alvo von Cossel I" <Al************@discussions.microsoft.com> escribió en
el mensaje news:F0**********************************@microsof t.com...
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+OPENFILEDIALOG 1.FILENAME;
}

WHAT AM I DOING (sorry about the sudden caps lock!) wrong?
--
Alvo von Cossel I of Germany

Nov 17 '05 #2

P: n/a
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
--
Alvo von Cossel I of Germany
"Octavio Hernandez" wrote:
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

"Alvo von Cossel I" <Al************@discussions.microsoft.com> escribió en
el mensaje news:F0**********************************@microsof t.com...
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+OPENFILEDIALOG 1.FILENAME;
}

WHAT AM I DOING (sorry about the sudden caps lock!) wrong?
--
Alvo von Cossel I of Germany


Nov 17 '05 #3

P: n/a
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

"Alvo von Cossel I" <Al************@discussions.microsoft.com> wrote in
message news:5C**********************************@microsof t.com...
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
--
Alvo von Cossel I of Germany
"Octavio Hernandez" wrote:
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

"Alvo von Cossel I" <Al************@discussions.microsoft.com> escribió en el mensaje news:F0**********************************@microsof t.com...
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+OPENFILEDIALOG 1.FILENAME;
}

WHAT AM I DOING (sorry about the sudden caps lock!) wrong?
--
Alvo von Cossel I of Germany


Nov 17 '05 #4

P: n/a
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.
Nov 17 '05 #5

P: n/a
hi,

it was code using visual basic anyway
--
Alvo von Cossel I of Germany
"Rachel Suddeth" wrote:
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.

Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.