I have a simple MS Access database with some rich text fields. I have been trying to
bind some RichTextBox controls in my form to these fields. When I used the following c# code:

Binding bd = new Binding("Text", ds, "Words.meaning", true);

ds= my DataSet
Words= my Table
meaning=A richtext field in my table

I got a non rich text tagged with rtf lables:
<div>text</div> which I do not need.
I want exactly the rich text to be displayed on the RichTextBox. So I binded the "Rtf" property of my richtextbox to the dataset:

Binding bd = new Binding("Rtf", ds, "Words.meaning", true);

But I got nothing on the RichTextBox.
I don't know why it is not showing anything!
Can you suggest a way to bind a richtextbox and get the proper results?
Thanks in advance


This is not the kind of RichText that the RichTextBox accepts.
That is more compatible with the WebBrowser.DocumentText property (i.e. HTML).
If you do not need the user to edit the text then try replacing the RichTextBox with a WebBrowser.
Then use this to do the binding.

Binding bind = new Binding("DocumentText", ds, "Words.Meaning", true, DataSourceUpdateMode.Never);

Otherwise you will need to change the formatting of the text in you Meaning field to match what the RichTextBox requires.

For the RTF codes, see "rich text format (RTF) Specification, version 1.6" in the MSDN library at http://msdn.microsoft.com/library.

Taken from MSDN help on RichTextBox.Rtf property.

(Note: Copy and pasting text from Word or Wordpad in to the RichTextBox will get the right format.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.