Add Image into richtextbox

Insert Image into Rich Textbox

Some times you might have a requirement to insert an Image into rich textbox in C#. So in this article we will learn about how to insert image into rich textbox in C#.

Requirements:

  1. Visual Studio 2010 or later version.

Steps to Follow:

  1. Create a new windows forms application project or open your existing project.
  2. Go to design View of your form and add a rich text box and a button to open the image.
  3. Go to the code view of your form and create simple method to add image like:

private void displayImage(string name)
{
Clipboard.SetImage(Image.FromFile(name));

richTextBox1.Paste();
}

4. Now go to the OnClick Event of button and add the following code:

 OpenFileDialog open = new OpenFileDialog();
            // image filters  
            open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.png; *.bmp)|*.jpg; *.jpeg; *.gif; *.png; *.bmp";
            if (open.ShowDialog() == DialogResult.OK)
           {
               displayImage(open.FileName);  
            }

Source Code:

I hope you enjoyed this article. Please don’t forget to subscribe our official YouTube Channel C# Ui Academy

3 Replies to “Insert Image into Rich Textbox”

  1. I think other web site proprietors should take this web site as an model, very clean and wonderful user genial style and design, as well as the content. You are an expert in this topic!

  2. Good post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis. It’s always interesting to read content from other authors and use something from other sites.

  3. You’re so interesting! I do not believe I’ve truly read anything like that before. So wonderful to find another person with some genuine thoughts on this topic. Seriously.. thanks for starting this up. This site is one thing that is needed on the web, someone with a little originality!

Comments are closed.