I have a RadGridView with 5 columns, 2 of which contain rich text. I'm using the following to embed RichTextBox inside my RadGridView.
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Procedure}"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
StackPanel
>
<
telerik:HtmlDataProvider
RichTextBox
=
"{Binding ElementName=richTextBox}"
Html
=
"{Binding Procedure, Mode=TwoWay}"
/>
<
telerik:RadRichTextBox
x:Name
=
"richTextBox"
IsReadOnly
=
"True"
/>
</
StackPanel
>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
My problem is that the grid is rendered very slowly. In my sample application, I only have 5 lines, so in total 10 rich text boxes and only half of them have actually data, which are very simple HTML and not more than 10 words each (no tables, just some bold words and some coloring).
If I try the same without the rich text boxes then the grid is rendered instantly. The same if I use the WebBrowser control to display my data.
What can I do?
9 Answers, 1 is accepted
The problem is caused by the enabled RadGridView virtualization. When a cell goes out of view the instance in it is destroyed and when a cell goes into view the instance is created again. Every time the instance in the cell is created, the binding happens again and it triggers parsing and visualizing the HTML.
You can turn off the virtualization of the RadGridView by setting EnableRowVirtualization and EnableColumnVirtualization properties to false, but then the performance of RadGridView may be hindered.
Overall RadRichTextBox is a rather heavy control and is not well-suited to be used in the template of a DataGrid or RadGridView. We will look into the performance issues, but it is not certain if a fix could be implemented.
Nikolay Demirev
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
RadRichTextBox control is quite heavy and not well-suited for such scenario.
One additional option you can try is to change the MEF's default composition container to one containing limited set of types, as described in this article - the bare minimum is to set empty type catalog:
RadCompositionInitializer.Catalog =
new
TypeCatalog();
<
telerik:RadRichTextBox
x:Name
=
"richTextBox"
IsReadOnly
=
"True"
IsSpellCheckingEnabled
=
"False"
/>
Regards,
Boby
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
Our tests show that it takes a little less than 4 s to show a GridView with two RadRichTextBox columns with 12 lines for the first time. Each of the next times that the GridView is shown takes about 1.5 s. These values are registered when the project is run in Release mode, without attached debugger.
As previously mentioned, the delay the first time the grid view is shown is caused by the fact that RadRichTextBox uses MEF to load the assemblies it needs. Removing the unnecessary assemblies - format providers not used, RichTextBoxUI and its dependencies, and setting the Catalog to an empty type catalog reduces the initial time to less than 3 seconds. Please, find attached a demo illustrating that.
As Boby mentioned, this is all that can be done to improve the performance. If you have other questions, do not hesitate to get back to us.
Iva Toteva
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
However, before proceeding with that, I would like to ask you if you have done any developments in this problem. Perhaps in a new release (for .NET 4) the editor's performance has significantly improved? Previously you told me that your rich text component was not made for such use. Is this statement still valid with the latest releases?
We have done some performance improvements but they are not specifically targeting your use case. You can test the performance at your side using the sample application provided by Iva (it should be runnable against the latest version without any issues) - and decide if it fits your needs.
All the best,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
What can I do if i have a performane problem while displaying HTML in a RichTextBox ( I implemented the binding as in the example in the toolkit )
I put the Richtextbox in a Dockpanel ( simpler than a Grid).
The binding data is stored as a string. In case it is simple HTML, the control displays it well but
my HTML contains a file path to a picture but the file does not exist, when running from visual studio debugger I can see the HTML without picture, Immediately but when not using the VS application, it takes long long time.
I set the properties of ReadOnly ( = true) & EnableSpellChecking(= false) and i still have a performance problem.
As I said in you other forum post about your issue, it will be of great help if you can open a new support ticket and attach the problematic document so we can examine it.
Mihail
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>