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

[Solved] Removing ImageInline components

1 Answer 142 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
edward
Top achievements
Rank 1
edward asked on 01 Aug 2011, 12:00 PM
How do I remove components ImageInline from a RadRichTextBox?

I made the following function to do that, but it doesn't work.

private static void removeImages(DocumentElementCollection children)
        {
            if (children.Count == 0) return;
 
            var layoutBox = children.First;
 
            var docElement = layoutBox.AssociatedDocumentElement;
            while (docElement != null)
            {
                docElement.Children.RemoveAll(element => element.GetType() == typeof(ImageInline));
                 
                removeImages(docElement.Children);
 
                docElement = docElement.NextSibling;
            }
        }
Can anyone provide some insight into this question? please...

1 Answer, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 03 Aug 2011, 01:40 PM
Hello Edward,

The following code will remove both ImageInlines and FloatingImageBlocks. If you need to only remove ImageInlines you can skip the second loop:
foreach(ImageInline imageInline indocument.EnumerateChildrenOfType<ImageInline>().ToArray())
{
    imageInline.Parent.Children.Remove(imageInline);
}
  
foreach(FloatingImageBlock floatingImageBlock indocument.EnumerateChildrenOfType<FloatingImageBlock>().ToArray())
{
    floatingImageBlock.Parent.Children.Remove(floatingImageBlock);
}

All the best,
Ivailo
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
RichTextBox
Asked by
edward
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Share this question
or