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

Inserting Bookmarks

3 Answers 116 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Stanescu Mihai
Top achievements
Rank 1
Stanescu Mihai asked on 24 Nov 2010, 03:54 PM
Hello, I would like to know if I can insert bookmarks in richtextbox, save the document as .docx format and later fill in the bookmarks with relative information.

If so, can you please give me some pointers.


Thanks, Michael.

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivailo Karamanolev
Telerik team
answered on 25 Nov 2010, 09:59 AM
Hi Stanescu Mihai,

I can not fully understand the functionality you desire, but if you have something like mail-merge in mind (having "placeholders" in certain positions in the document and then replace them with specific information), then looking at the next find-replace functionality will get you started. More on this you can find here.
If rather than that, you mean bookmarks appearing in Word as certain positions of interest in the document, unfortunately, there is still no support for this. We have planned to add support for more advanced functionality such as this, but we currently haven't scheduled it so no specifics are available.

Greetings,
Ivailo
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Stanescu Mihai
Top achievements
Rank 1
answered on 25 Nov 2010, 01:10 PM
Thanks Ivailo, this is in fact what I am looking, for a "placeholder" which will be replaced by some text. Unfortunately I am having some problem selecting the text I want to replace, apparently I can only select it after a user initiated event. I was hoping to do this when it loads. Any hints on this?
0
Ivailo Karamanolev
Telerik team
answered on 25 Nov 2010, 03:06 PM
Hi Stanescu Mihai,

I have taken the demo posted at the thread I gave you a link to. What you need basically is to hook to the Loaded event of the UserControl (the parent of the RadRichTextBox or the RadRichTextBox itself) and perform the logic as shown in the demo. Please note that there's a small modification you need to make in order to have this working: calling the Measure method as it's needed for the Find to operate... and here's the code:
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
    this.radRichTextBox.Document = LoadXamlFile();
 
    this.radRichTextBox.Document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
             
    this.radRichTextBox.Document.Selection.Clear();
 
    DocumentTextSearch search = new DocumentTextSearch(this.radRichTextBox.Document);
    foreach (var textRange in search.FindAll(this.textBox.Text))
    {
        this.radRichTextBox.Document.Selection.AddSelectionStart(textRange.StartPosition);
        this.radRichTextBox.Document.Selection.AddSelectionEnd(textRange.EndPosition);
    }
}
Let us know if you need further assistance.

Regards,
Ivailo
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
RichTextBox
Asked by
Stanescu Mihai
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Stanescu Mihai
Top achievements
Rank 1
Share this question
or