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

how to delete the control and rebind the text to editor

1 Answer 60 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, 09:38 PM

hi ,

i have followed your sample code to add a button control  to text editor
when the button is clicked , i only want to delete the button & rebind the entire text  to editor
is it possible ,if so how ?

please help me
Thanks in Advance
satish


code is :


RadDocument doc = new RadDocument();
 
Section section = new Section();
doc.Sections.Add(section);
 
Paragraph paragraph = new Paragraph();
section.Paragraphs.Add(paragraph);
 
Span span = new Span("Some Text before...");
paragraph.Inlines.Add(span);
 
Button button = new Button();
button.Name = "id_212";
button.Content = "Test Button";
button.Width = 100;
button.Height = 50;
 
button.Click += 
    (s, a) => 
    {
/////        MessageBox.Show("Your button was just clicked!");
    };
 
InlineUIContainer container = new InlineUIContainer();
container.UiElement = button;
container.Width = button.Width;
container.Height = button.Height;
 
paragraph.Inlines.Add(container);
 
Span span2 = new Span("Some Text after...");
paragraph.Inlines.Add(span2);
 
editor.Document = doc;

1 Answer, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 08 Sep 2010, 03:59 PM
Hello Satish,
You can do this task with the following code:
RadDocument doc = new RadDocument();
 
Section section = new Section();
doc.Sections.Add(section);
 
Paragraph paragraph = new Paragraph();
section.Paragraphs.Add(paragraph);
 
Span span = new Span("Some Text before...");
paragraph.Inlines.Add(span);
 
Button button = new Button();
button.Content = "Test Button";
button.Width = 75;
button.Height = 23;
 
InlineUIContainer container = new InlineUIContainer();
container.UiElement = button;
container.Width = button.Width;
container.Height = button.Height;
 
paragraph.Inlines.Add(container);
 
button.Click +=
    (s, a) =>
    {
        paragraph.Inlines.Remove(container);
        radRichTextBox.UpdateEditorLayout();
    };
 
Span span2 = new Span("Some Text after...");
paragraph.Inlines.Add(span2);
 
radRichTextBox.Document = doc;

Please let us know if this works for you.

Greetings,
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