?
Solved

How to load html file to richtextbox ?

Posted on 2011-05-04
9
Medium Priority
?
1,980 Views
Last Modified: 2012-08-14
Hi!

Have this code in vb.net to load html document to a richtextbox

Me.txtBody.LoadFile("C:\testmal2.htm", RichTextBoxStreamType.RichText)


But it dosent work ?
Get an error message that say that fileformat dosent axepted..

How can i load this html document to my richtextbox ?
0
Comment
Question by:team2005
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 35688458
Check this Sample to Load HTML File in RichTextBox

http://www.codeproject.com/KB/edit/htmlrichtextbox.aspx
0
 
LVL 12

Expert Comment

by:Paul_Harris_Fusion
ID: 35688469
Rich text is completely different to HTML.

if you simply want to display an HTML file, use the System.Windows.Forms.webBrowser control instead.

If you put one of these on your form, you can display the html with the following code

    Private Sub SetBrowserText(ByVal Text As String)

        With myWebBrowserControl
            .Stop()
            .Document.OpenNew(False)
            .Document.Write(Text)
            .Refresh()
            .AllowNavigation = False
        End With

End Sub
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 35688475
do you need to edit it or just display it?

to simply display the content, you can use a webbrowser control.

to edit it, you can use a control like http://xstandard.com/
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:team2005
ID: 35688558
Hi!

I MUST load this into the textbox.

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 35688571
a plain old textbox cannot render HTML so you cannot use that control
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35688607
Do you want to Load the file or Render the file in the rich text box?
0
 
LVL 2

Author Comment

by:team2005
ID: 35688644
Hi!

Load the file :)
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 35688650
In that case

txtBody.Text = IO.File.ReadAllText("C:\testmal2.htm")
0
 
LVL 2

Author Closing Comment

by:team2005
ID: 35688678
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month16 days, 18 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question