Hi,
I have a uerControl, MyUserControl, that contains a RadRichTextEditor. The method that initializes MyUserControl instantiates a new RadDocument for the RadRichTextEditor. The new document is sometimes empty (no sections) and sometimes has one section that contains a paragrph!!! I have the following code to remove the initial paragraph (2 versions) and they both crash. What is the right way of doing it?
public void InitMyUserControl()
{
textEditor.RichTextBoxElement.BackColor = Color.White;
textEditor.Document = new RadDocument();
if ( textEditor.Document.Sections.Count != 0)
{
var block = textEditor.Document.Sections.First.Blocks.First;
textEditor.Document.Sections.First.Blocks.Remove(block);
}
OR
if ( textEditor.Document.Sections.Count != 0)
{
Section section = textEditor.Document.Sections.First;
textEditor.Document.Sections.Remove(section);
}
}
Thanks,
Shahrzade.