Code Snippet
private void btnInsertImage_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "Insert Image File";
openFileDialog1.Filter = "Bitmap Files|*.bmp|JPEG Files|*.jpg|GIF Files|*.gif";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
string strImagePath = openFileDialog1.FileName;
Bitmap img = new Bitmap(strImagePath);
Clipboard.SetDataObject(img);
DataFormats.Format df;
df = DataFormats.GetFormat(DataFormats.Bitmap);
if (this.richTextBox1.CanPaste(df))
{
this.richTextBox1.Paste(df);
}
}
catch
{
MessageBox.Show("Unable to insert image format selected.");
}
}
}