This is a migrated thread and some comments may be shown as answers.

Fan4u

1 Answer 69 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
satish
Top achievements
Rank 1
satish asked on 03 Sep 2010, 08:57 AM

How can we add a  button control to rich text box editor

there is sample code to add text  , but i dont find it for button, textbox etc control .

thanks

RadDocument document = new RadDocument();
document.LayoutMode = DocumentLayoutModes.Paged;
document.PageLayoutSettings.Width = 200;
document.PageLayoutSettings.Height = 120;
Section section =
new Section();
section.PageMargin =
new Padding( 20 );
document.Sections.Add( section );
Paragraph paragraph =
new Paragraph();
section.Paragraphs.Add( paragraph );
Span span =
new Span( "This a RadDocument " );
span.ForeColor = Colors.Green;
paragraph.Inlines.Add( span );
span =
new Span( "created in code" );
span.FontWeight = FontWeights.Bold;
paragraph.Inlines.Add( span );
paragraph =
new Paragraph();
paragraph.TextAlignment = RadTextAlignment.Center;
section.Paragraphs.Add( paragraph );
span =
new Span( "This paragraph is aligned Center" );
span.HighlightColor = Colors.Yellow;
paragraph.Inlines.Add( span );
this.radRichTextBox.Document = document;

1 Answer, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 03 Sep 2010, 02:45 PM
Hi Satish,

You can add Button in RadRichTextBox with code similar to this sample:
Button button = new Button() { Content = "Button" };
InlineUIContainer container = new InlineUIContainer(button, new Size(75, 23));
 
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add(container);
 
Section section = new Section();
section.Paragraphs.Add(paragraph);
 
RadDocument document = new RadDocument();
document.Sections.Add(section);
 
radRichTextBox.Document = document;

Keep in mind that currently we do not support serializing InlineUIContainers, so documents like this one will not be saved/loaded correctly (you can refer to this thread).

Regards,
Boby
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
satish
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or