This is a migrated thread and some comments may be shown as answers.
Bad UI performance when using RichTextBox inside a RadGridView
9 Answers 118 Views
This is a migrated thread and some comments may be shown as answers.
papadi
Top achievements
Rank 1
papadi asked on 17 Sep 2012, 02:01 PM
Hi!
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

Sort by
0
Nikolay Demirev
Telerik team
answered on 20 Sep 2012, 03:08 PM
Hello,

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.

Kind regards,
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.

0
papadi
Top achievements
Rank 1
answered on 20 Sep 2012, 03:28 PM
Setting False to these two properties didn't affect at all the behavior. I get exactly the same delay.
0
Boby
Telerik team
answered on 26 Sep 2012, 09:14 AM
Hi Papadi,
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();
You can also try to disable the spell checking functionality:
<telerik:RadRichTextBox x:Name="richTextBox" IsReadOnly="True" IsSpellCheckingEnabled="False"  />
Despite these there isn't much you can do to improve the performance in this specific scenario.


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.

0
papadi
Top achievements
Rank 1
answered on 26 Sep 2012, 09:39 AM
Thanks but this didn't help either. No visible effect on the performance.
0
Iva Toteva
Telerik team
answered on 01 Oct 2012, 10:25 AM
Hi papadi,

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.

Regards,
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.

0
papadi
Top achievements
Rank 1
answered on 21 Mar 2013, 03:33 PM
We are considering using an alternative html editor instead of telerik's one because of this problem.
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?
0
Boby
Telerik team
answered on 25 Mar 2013, 05:17 PM
Hi papadi,

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.

0
Dafna
Top achievements
Rank 1
answered on 21 Oct 2013, 08:10 AM
I wrote a  WPF application.
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.
0
Mihail
Telerik team
answered on 23 Oct 2013, 08:18 AM
Hello Dafna,

 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.

Regards,
Mihail
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
Asked by
papadi
Top achievements
Rank 1
Answers by
Nikolay Demirev
Telerik team
papadi
Top achievements
Rank 1
Boby
Telerik team
Iva Toteva
Telerik team
Dafna
Top achievements
Rank 1
Mihail
Telerik team
Share this question
or