Hello Telerik,
I experienced performance drop with RadRichTextBox, if a huge number of characters present in a single span and the user tries to delete some part of the text. I attached a sample code which loads a 'huge' string in RadRichTextBox. To be more specific i created a single Span inside the document and added a 20.000 length string.
MainPage.xaml:
MainPage.xaml.cs
Reproduction scenario:
1. Open the sample application
2. Scroll down to the middle of the document
3. Select 4 or 5 lines inside the document
4. Press delete key.
5. Deletion takes relatively slow (~2 sec or more)
Is this really a performance issue? Is it a valid use case that the user will type 20000 character in a single line (without pressing 'enter')?
Best Regards,
Janos
I experienced performance drop with RadRichTextBox, if a huge number of characters present in a single span and the user tries to delete some part of the text. I attached a sample code which loads a 'huge' string in RadRichTextBox. To be more specific i created a single Span inside the document and added a 20.000 length string.
MainPage.xaml:
<
StackPanel
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
TextBox
Name
=
"textbox1"
/>
<
telerik:RadRichTextBox
Name
=
"radRichTextBox1"
Height
=
"500"
BorderBrush
=
"SlateBlue"
BorderThickness
=
"1"
IsSpellCheckingEnabled
=
"False"
PreviewEditorKeyDown
=
"radRichTextBox1_PreviewEditorKeyDown"
CommandExecuted
=
"radRichTextBox1_CommandExecuted"
/>
</
StackPanel
>
MainPage.xaml.cs
public
partial
class
MainPage : UserControl
{
public
MainPage()
{
InitializeComponent();
Init();
}
private
DateTime startTime;
// 32 characters
private
const
string
SAMPLETEXT =
"sample text to fill richtextbox "
;
private
void
Init()
{
StringBuilder stringBuilder =
new
StringBuilder();
for
(
int
i = 0; i < 625; i++)
{
stringBuilder.Append(SAMPLETEXT);
}
textbox1.Text =
string
.Format(
"Inital string lenght: {0}"
, stringBuilder.Length);
// create span with sample text
Span span =
new
Span() { Text = stringBuilder.ToString() };
Paragraph paragraph =
new
Paragraph();
paragraph.Children.Add(span);
Section section =
new
Section();
section.Children.Add(paragraph);
RadDocument document =
new
RadDocument();
document.Sections.Add(section);
this
.radRichTextBox1.Document = document;
}
private
void
radRichTextBox1_PreviewEditorKeyDown(
object
sender, PreviewEditorKeyEventArgs e)
{
if
(e.Key == Key.Delete)
{
this
.startTime = DateTime.Now;
}
}
private
void
radRichTextBox1_CommandExecuted(
object
sender, CommandExecutedEventArgs e)
{
if
(e.Command
is
DeleteCommand)
{
TimeSpan elapsedTime = DateTime.Now - startTime;
this
.textbox1.Text =
string
.Format(
"DeleteCommand executed in {0} ms"
, elapsedTime.TotalMilliseconds.ToString());
}
}
}
Reproduction scenario:
1. Open the sample application
2. Scroll down to the middle of the document
3. Select 4 or 5 lines inside the document
4. Press delete key.
5. Deletion takes relatively slow (~2 sec or more)
Is this really a performance issue? Is it a valid use case that the user will type 20000 character in a single line (without pressing 'enter')?
Best Regards,
Janos