Use the code below.
1. Click the first button to insert a link.
2. Click inside the link to move the cursor.
3. Click the second button to insert the yellow rectangle
4. Click the third button to export the HTML content.
Actual result: StackOverflow exception occurs
private void radButton1_Click(object sender, EventArgs e)
{
HyperlinkInfo info = new HyperlinkInfo()
{
NavigateUri = "http://www.google.com",
Target = HyperlinkTargets.Blank,
IsAnchor = false
};
this.radRichTextEditor1.InsertHyperlink(info, "www.google.com");
}
private void radButton2_Click(object sender, EventArgs e)
{
LightVisualElement button = new LightVisualElement();
button.Text = "My Button";
button.DrawFill = true;
button.BackColor = System.Drawing.Color.Yellow;
button.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
Section section = new Section();
Paragraph paragraph = new Paragraph();
InlineUIContainer container = new InlineUIContainer();
RadElementUIContainer radContainer = new RadElementUIContainer(button);
container.UiElement = radContainer;
container.Height = 25;
container.Width = 70;
paragraph.Inlines.Add(container);
section.Blocks.Add(paragraph);
RadDocument doc = new RadDocument();
doc.Sections.Add(section);
radRichTextEditor1.InsertFragment(new DocumentFragment(doc));
}
private void radButton3_Click(object sender, EventArgs e)
{
Telerik.WinForms.Documents.Model.RadDocument document = radRichTextEditor1.Document;
Telerik.WinForms.Documents.FormatProviders.Html.HtmlFormatProvider provider = new Telerik.WinForms.Documents.FormatProviders.Html.HtmlFormatProvider();
provider.ExportSettings.InlineUIContainerExporting += ExportSettings_InlineUIContainerExporting;
provider.ExportSettings.DocumentExportLevel = Telerik.WinForms.Documents.FormatProviders.Html.DocumentExportLevel.Fragment;
provider.ExportSettings.ExportFontStylesAsTags = true;
provider.ExportSettings.SpanExportMode = Telerik.WinForms.Documents.FormatProviders.Html.SpanExportMode.DefaultBehavior;
string htmlValue = provider.Export(document);
webBrowser1.DocumentText = htmlValue;
}
private void ExportSettings_InlineUIContainerExporting(object sender, Telerik.WinForms.Documents.FormatProviders.Html.InlineUIContainerExportingEventArgs e)
{
}