473,395 Members | 1,783 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,395 software developers and data experts.

inserting images into richtextbox

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

Similar topics

1
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...
2
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...
1
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...
2
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
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). ...
1
by: farrukhqadri786 | last post by:
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. ...
0
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...
0
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...
1
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)....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
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.