private void InsertImage()
        {
            OpenFileDialog openImageDlg = new OpenFileDialog();
            openImageDlg.Filter = "所有图片(*.bmp,*.gif,*.jpg)|*.bmp;*.gif;*jpg";//格式过滤s
            openImageDlg.Title = "选择图片";

            Bitmap bmp;
            if (openImageDlg.ShowDialog() == DialogResult.OK)
            {
                string fileName = openImageDlg.FileName;
                if (null == fileName || fileName.Trim().Length == 0)
                    return;
                try
                {
                    bmp = new Bitmap(fileName);
                    Clipboard.SetDataObject(bmp);//将数据置于系统剪贴板中
                    DataFormats.Format dataFormat = DataFormats.GetFormat(DataFormats.Bitmap);//格式
                    if (richTextBox1.CanPaste(dataFormat))
                        richTextBox1.Paste(dataFormat);
                }
                catch (Exception exc)
                {
                    MessageBox.Show("图片插入失败。" + exc.Message, "提示",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }

相关文章:

  • 2021-07-27
  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-11-08
  • 2021-09-24
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2021-08-08
  • 2021-09-29
  • 2022-12-23
  • 2021-08-07
  • 2021-07-14
  • 2022-02-16
相关资源
相似解决方案