//设置对话框的过滤条件
ofdSelectPic.Filter = "png文件(*.png)|*.png|jpg 文件(*.jpg)|*.jpg|所有文件(*.*)|*.*";
ofdSelectPic.Title = "打开图片";
ofdSelectPic.FilterIndex = 2;
if (ofdSelectPic.ShowDialog() == DialogResult.OK)
{
try
{
Bitmap bmp = new Bitmap(ofdSelectPic.FileName);//获得图片
Clipboard.SetDataObject(bmp, false);//将图片放在剪贴板中
if (rtbArticles.CanPaste(DataFormats.GetFormat(DataFormats.Bitmap)))
rtbArticles.Paste();//粘贴数据
}
catch (Exception)
{
MessageBox.Show("请选择正确的图片");
}
}