title: Insert Image at Cursor Position in Rich Text box
body: <p>I know there are various questions like this but i'm asking because i couldn't understand all the answers give. I have <code>RichTextBox</code> and i want the user to be able to insert an image at the current cursor position.</p>
  
  <p>I have tried using the <code>Clipboard</code> to set the Image and then pasting it in the rich textbox. This works but i've been told its bad practice as it change data in a cliboard without notifying the user.</p>
  
  <p>This is what i have tried</p>
  
  <pre><code>    private bool CheckIfImage(string filename)
      {
          if (filename.EndsWith(".jpeg")) { return true; }
          else if (filename.EndsWith(".jpg")) { return true; }
          else if (filename.EndsWith(".png")) { return true; }
          else if (filename.EndsWith(".ico")) { return true; }
          else if (filename.EndsWith(".gif")) { return true; }
          else if (filename.EndsWith(".bmp")) { return true; }
          else if (filename.EndsWith(".emp")) { return true; }
          else if (filename.EndsWith(".wmf")) { return true; }
          else if (filename.EndsWith(".tiff")) { return true; }
          else { return false; }
      }
  
      private void openFileDialog2_FileOk(object sender, CancelEventArgs e)
      {
          if (CheckIfImage(openFileDialog2.FileName.ToLower()) == true)
          {
              Image img = Image.FromFile(openFileDialog2.FileName);
              string setData = (String)Clipboard.GetData(DataFormats.Rtf);
  
              Clipboard.SetImage(img);
              rtbType.Paste();
  
              Clipboard.SetData(DataFormats.Rtf, setData);
          }
          else
          {
              MessageBox.Show("Invalid Image File Selected");
          } 
      }
  </code></pre>
  
  <p>Pls is there any better way to do this?</p>