This is a migrated thread and some comments may be shown as answers.

Inserting text into the RichTextBox

2 Answers 230 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Ronald Evers
Top achievements
Rank 1
Ronald Evers asked on 26 May 2010, 12:42 PM
Hello again,

Sorry about all the questions about this control. There isn't really any documentation as of yet so I'm kind of working blind I guess.
Basically what I want is a "Stamp" function that inserts a datetime into the textbox in bold at the very start of the page, with an enter after it. I managed to insert the datetime but at the moment I can only insert it in the place where the cursor is, not at the start.

Here's what I used:

 radRichTextBox.Document.InsertAtCaretPosition(DateTime.Now.ToShortDateString(), null);

So yeah, is there any way to insert this at the start of the document? Maybe make it bold and put an new empty line under it?
Any help would be greatly appreciated.



2 Answers, 1 is accepted

Sort by
0
Ronald Evers
Top achievements
Rank 1
answered on 26 May 2010, 01:02 PM
Ok I got a bit further now but it's not doing what I want it to. the code is now:
radRichTextBox.Document.CaretPosition.MoveToFirstPositionInDocument();                
radRichTextBox.Document.InsertAtCaretPosition(DateTime.Now.ToShortDateString() + Environment.NewLine, null);


Now it adds the datetime plus a new line to the start of the document. However it doesn't seem to update the text. After I do this I can't see it appear until I actually type something or change the font to bold or whatever.
0
Mike
Telerik team
answered on 26 May 2010, 02:01 PM
Hello Ronald Evers,

We are glad you found the right API to use in this case. In order to solve your issue you should add the following call:

radRichTextBox.UpdateEditorLayout();
The problem here is that in the current CTP version RadRichTextBox does not update automatically when changes in the document occur through API. We will conciser improving the behavior in this case. By the way, the documentation for the CTP can be found here:
http://www.telerik.com/help/silverlight/radrichtextbox-overview.html
We know its not much but it can help in the general cases.

Let us know if we can help with anything else.

Regards,
Mike
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.
Tags
RichTextBox
Asked by
Ronald Evers
Top achievements
Rank 1
Answers by
Ronald Evers
Top achievements
Rank 1
Mike
Telerik team
Share this question
or