4 Answers, 1 is accepted
0
Hello Oliver,
DocumentContentChanged is a relatively special event. It is not fired when the change happens, but instead the change triggers a timer which dispatches the event with a delay. This is done to ease the development in cases where heavy computation happens in the event handler. The delay is controlled by the DocumentContentChangedInterval property. This means that you cannot know precisely when it will be fired.
Regards,
Ivailo
the Telerik team
DocumentContentChanged is a relatively special event. It is not fired when the change happens, but instead the change triggers a timer which dispatches the event with a delay. This is done to ease the development in cases where heavy computation happens in the event handler. The delay is controlled by the DocumentContentChangedInterval property. This means that you cannot know precisely when it will be fired.
Regards,
Ivailo
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
0
xusan Rahimov
Top achievements
Rank 1
answered on 09 Aug 2011, 09:07 AM
Hi team,
I need your help, I want to replace some tokens in my document with some words from my appSetting in loading stage(in runtime), for example initialy word document contains the following text:
I used your replace api as described in Documentation API but it works correct when document is loaded, but when I use it in loading document/in runtime some tokens is not replaced correctly and sometime I get NullReference exception
You can try to reproduce it, just call replace method after word document is imported:
RadDocument doc = null;
using (System.IO.Stream fileStream = stream)
{
IDocumentFormatProvider docxProvider = new DocxFormatProvider();
doc = docxProvider.Import(fileStream);
fileStream.Close();
this.editor.Document = doc;
}
//Replace all tokens
ReplaceAllMatches("token1", "Firtst");
ReplaceAllMatches("token2", "Second");
ReplaceAllMatches("token3", "Third");
ReplaceAllMatches("token4", "Fourth");
ReplaceAllMatches("token5", "Fiveth");
ReplaceAllMatches("token6", "Sixth");
ReplaceAllMatches("token7", "Seventh");
ReplaceAllMatches("token8", "Eghtyth");
Can you please send me some advise or code to help replace all tokens in runtime/in loading stage?
Thanks in addvance
Khasan
I need your help, I want to replace some tokens in my document with some words from my appSetting in loading stage(in runtime), for example initialy word document contains the following text:
Birthday on token2, token3
Person: token1
token5, token6token7
token8
Birthday on 22.12.1999, 22:00
Person: Lokesh Samandar
Program, 40days
Jared
I used your replace api as described in Documentation API but it works correct when document is loaded, but when I use it in loading document/in runtime some tokens is not replaced correctly and sometime I get NullReference exception
You can try to reproduce it, just call replace method after word document is imported:
RadDocument doc = null;
using (System.IO.Stream fileStream = stream)
{
IDocumentFormatProvider docxProvider = new DocxFormatProvider();
doc = docxProvider.Import(fileStream);
fileStream.Close();
this.editor.Document = doc;
}
//Replace all tokens
ReplaceAllMatches("token1", "Firtst");
ReplaceAllMatches("token2", "Second");
ReplaceAllMatches("token3", "Third");
ReplaceAllMatches("token4", "Fourth");
ReplaceAllMatches("token5", "Fiveth");
ReplaceAllMatches("token6", "Sixth");
ReplaceAllMatches("token7", "Seventh");
ReplaceAllMatches("token8", "Eghtyth");
Can you please send me some advise or code to help replace all tokens in runtime/in loading stage?
Thanks in addvance
Khasan
0
Hi Khasan,
Could you try invoking this method after loading the document and before invoking the ReplaceAllMatches method and let us know if it does not help.
On a side note, in Q2 2011 we introduced merge fields, which should be able to fit your scenario much better than the programmatic find and replace. You can preview them in our online Telerik Demo, using the buttons in the Mailings tab of the ribbon UI. As you can see by switching to the Source tab in the top-right corner, the buttons are bound to commands of the editor, but there are also respective methods for inserting merge fields, updating the state of the merge field, etc. You should also note how the mail merge data source is set:
Iva
the Telerik team
In the previous versions of the control, RadRichTextBox's document had to be measured and arranged before some operations could be performed on it. The document is measured by the framework when it is shown on screen, but if you need to perform some modifications before that, you had to manually invoke the following method:
public
void
MeasureAndArrangeInDefaultSize(RadDocument document)
{
document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
document.Arrange(
new
RectangleF(PointF.Empty, document.DesiredSize));
}
Could you try invoking this method after loading the document and before invoking the ReplaceAllMatches method and let us know if it does not help.
On a side note, in Q2 2011 we introduced merge fields, which should be able to fit your scenario much better than the programmatic find and replace. You can preview them in our online Telerik Demo, using the buttons in the Mailings tab of the ribbon UI. As you can see by switching to the Source tab in the top-right corner, the buttons are bound to commands of the editor, but there are also respective methods for inserting merge fields, updating the state of the merge field, etc. You should also note how the mail merge data source is set:
this
.editor.Document.MailMergeDataSource.ItemsSource = new
ExamplesDataContext().Employees;
Then, you can insert merge fields in the following way:
this
.editor.InsertField(newMergeField() { PropertyPath =
"FirstName"
});
provided that the Employee class has a FirstName property.
All the best,Iva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
xusan Rahimov
Top achievements
Rank 1
answered on 14 Aug 2011, 01:13 PM
Hi Iva,
Thanks for help, I invoked this method and it resolved my problem.
Thanks
Khasan
Thanks for help, I invoked this method and it resolved my problem.
Thanks
Khasan