好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Winform开发时RichTextBox中添加图片的方法

Winform开发时RichTextBox中添加图片的方法

//设置对话框的过滤条件

OpenFileDialog hdhcmsPic=new OpenFileDialog();

hdhcmsPic.Filter = "png文件(*.png)|*.png|jpg 文件(*.jpg)|*.jpg|所有文件(*.*)|*.*";

hdhcmsPic.Title = "打开图片";

hdhcmsPic.FilterIndex = 2;

if (hdhcmsPic.ShowDialog() == DialogResult.OK)

{

  try

  {

    Bitmap bitHdhCms = new Bitmap(hdhcmsPic.FileName);//获得图片

    Clipboard.SetDataObject(bitHdhCms, false);//将图片放在剪贴板中

    if (rtbArticles.CanPaste(DataFormats.GetFormat(DataFormats.Bitmap)))

    rtbArticles.Paste();//粘贴数据

  }

  catch (Exception)

  {

    MessageBox.Show("请选择正确的图片数据");

  }

}


查看更多关于Winform开发时RichTextBox中添加图片的方法的详细内容...

  阅读:14次