RichTextBox bound to string field in dataset shows the RTF codes

Posted on 2006-05-08
Last Modified: 2007-12-19
I have an ap in VS 2005.  A form is bound to a dataset.  A RichTextBox is bound to a string field which contains RTF Text.  Most of the data was entered in a similar program witten in VB6.  Now all the RTF codes are visible in the text box - it seems to be showing them as plain text without interpreting them.  If I enter new data in an empty record it works fine - the text is visible without the RTF codes.  It worked OK in VS2003 once I bound the data to the correct property of the RichTextBox but VS2005 does not seem to let you do that.

How doI get the formatted text to appear correctly?
Question by:MikeVE
    LVL 34

    Accepted Solution

    VB.NET 2005 will allow you to do it.  But you have to do it in code as the RichTextBox's .rtf property does not appear in the IDE GUI.  These lines are working for me in a quick VB.NET 2005 test form I just coded.

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            'TODO: This line of code loads data into the 'TestDataSet.MyRTF' table. You can move, or remove it, as needed.
            RichTextBox1.DataBindings.Add("rtf", BindingSource1, "MyText")
        End Sub

    One other problem that I've experienced is that on saving .rtf to a database the coded string has had a Chr(0) added at the end and, when that is read back, it throws the display.  Here's a post that touches on that


    Author Comment

    Thanks Roger

    That did the trick.  I checked the names of the two RichTextBoxes concerned and searched the Designer.vb file for the relevant Databinding line, copied them to the ordinary file and there changed the "Text" parameter to "RTF".

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now