How to bind to a richtextbox/document

2 posts, 0 answers
  1. Olga
    Olga avatar
    14 posts
    Member since:
    Mar 2011

    Posted 31 Mar 2011 Link to this post


    I have a database, where there are two columns called title and description that both contain text/strings. In the SL I have a treelist view that I bound to my database that displays the titles. I also have a rich textbox in the SL application I would like to bind to my description column. As I click through the title in the tree, I would like the description in my richtextbox to change depending on what title I select in the tree. I want to also to be able to change the font of the description in the rich textbox. I tried adding a raddocument to my rich text box and then binding the description to the Span of the document (I did this my creating a custom property). It works, but it is not a two way binding. I want the user to be able to change the description in the textbox, and when he clicks save to update the database. Any help would be appreciated.

  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 05 Apr 2011 Link to this post

    Hi Olga,

    There is a similar demo in this forum thread. It keeps the titles of the documents in a list box and not a treelist view, but the approach should be quite similar. You can use HtmlDataProvider, XamlDataProvider and RtfDataProvider to bind the content of the document. There is also a TxtDataProvider, that strips the text from all formatting. You can find more information on the use of data providers in this article.
    As it comes to setting the font properties of the text in the rich text box, if you set a font family and font size on the rich text box and the property DocumentInheritsDefaultStyleSettings="True", these default values will be applied to all spans that do not have explicitly set font family/size. In case you wish to change the font settings on the whole text, you can programmatically select the whole document and invoke the corresponding methods like this:

    this.richTextEditor.ChangeFontFamily(new FontFamily("Comic Sans MS"));

    Best wishes,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top