Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8132045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:15:01+00:00 2026-06-06T09:15:01+00:00

I am looking for a way to embed image to Rich text box. My

  • 0

I am looking for a way to embed image to Rich text box. My rtf file is portable which contains both image and text. i.e. It can be moved from one computer to another. So the user should be able to see the content of rtf file (text+image) even if its in another machine.

Now I am using the following code to insert image.

public static void ApplyImage(RichTextBox RichTextBoxControl)
{
    try
    {
        Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
        dlg.DefaultExt = ".png";
        dlg.Filter = "PNG Files (.png)|*.png|JPG Files (.jpg)|*.jpg|GIF Files (.gif)|*.gif";
        Nullable<bool> result = dlg.ShowDialog();
        if (result == true)
        {
            string fileName = dlg.FileName;
            if (File.Exists(fileName))
            {
                BitmapImage bi = new BitmapImage(new Uri(fileName));
                Image image = new Image();
                image.Source = bi;
                InlineUIContainer container = new InlineUIContainer(image);
                Paragraph paragraph = new Paragraph(container);
                RichTextBoxControl.Document.Blocks.Add(paragraph);
            }
        }
    }
    catch
    {
        throw;
    }
}

But this code is not suitable for my purpose. Because the embedded image may not be in the other machine. So it won’t work. Either I need to embed image or store image as binary in rtf file. I searched everywhere and no luck.

Can anyone help me please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:15:02+00:00Added an answer on June 6, 2026 at 9:15 am

    I got a solution for the problem. I am not sure its the right way, but still this solution is working for me. Hope it may help others.

    The solution is to iterate through all image tags in flow document and copy the images to a repository folder which is portable. Then load the images from that repository folder next time to show the images back in to richtextbox.

    foreach (Block block in rtb.Blocks)
            {
                if (block is Paragraph)
                {
                    Paragraph paragraph = (Paragraph)block;
                    foreach (Inline inline in paragraph.Inlines)
                    {
                        if (inline is InlineUIContainer)
                        {
                            InlineUIContainer uiContainer = (InlineUIContainer)inline;
                            if (uiContainer.Child is Image)
                            {
                                Image image = (Image)uiContainer.Child;
    //Copy Image source to another repository folder and save the path.
                            }
                        }
                    }
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

simple question: I'm looking for a standards compliant way to embed a flash file.
I was recently looking for some way to embed an Adobe PDF file reader
I am looking for a way to embed a 360 modeling image on my
My problem is that I was looking for way to use both storyboard and
Looking for a way to get path of file (and then process it in
I'm looking for a way to embed Flash into a XHTML Transitional page that
By looking at current Google wave APIs, I can't find a way to create
Is there a way to use an image with an app_offline file? I'd like
I'm looking for a way to embed a cmd Shell into a Form. I
I am looking for a way to embed a blog engine into my own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.