Results 1 to 5 of 5

Thread: [RESOLVED] RichTextBox Question - Simple

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    36

    Resolved [RESOLVED] RichTextBox Question - Simple

    I'm experimenting with MySQL Database connection and modification right now. In my database I have an ArticlesTable which contains hundreds of HTML formatted articles. When I load the contents of these into a RichTextBox, I don't get what I assumed I would get. None of the font-formatting tags are Displayed 'Richly'.

    Am I missing the true use of the RichTextBox? If not, how can I get the HTML rendering-results that I'm looking for?

    Actually, I would like to have a box like this that I'm typing in if possible

    Jonathan

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: RichTextBox Question - Simple

    Yes you are missing the true use. A RichTextBox displays text in Rich Text Format (RTF). It uses markup tags like HTML but they are completely different tags. Type some text into a RichTextBox and then take a look at its Rtf property for an example. If you want to render HTML then you use a WebBrowser control. Of course, you can't type into that. There are probably WYSIWYG HTML editor controls available for the .NET platform but I doubt that they're free. An alternative would be to convert the HTML to RTF yourself before displaying in an RTB, then convert back to HTML afterwards. Any complex formatting in either would require some work to convert though. Another alternative would be to use Microsoft Word to do the conversion as it understands both formats. It would have to be installed to be used though, and it's not known for producing "clean" HTML code.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    36

    Re: RichTextBox Question - Simple

    Sounds good;

    I suppose I could build a simple little text-formatting thing. Thank you for the input though

    Jonathan

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    36

    Re: RichTextBox Question - Simple

    Is it possible to get a webbrowser (within VB) to display the .text of a textbox and include HTML formatting?

    So I can edit the html code in my textbox, and view it in a browser.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    36

    Re: RichTextBox Question - Simple

    WebBrowswer1.DocumentText = TextBox1.Text

    That solves the problem

    Also, you can apply source-formatting buttons by doing this:

    Create a button, "Make Text Bold" ... When this button is pressed, have it perform the following action

    TextBox1.SelectedText = "<b>" & TextBox1.SelectedText & "</b>"

    This will add HTML bold tags around whatever is selected.

    Hope this helps!

    Jonathan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width