.
在RichTextBox控件中插入图片
关键点
.
实现过程
.
public void ShowInsertImageDlg() { OpenFileDialog OpenFileDialog1 = new OpenFileDialog(); OpenFileDialog1.Title = "Select Image"; OpenFileDialog1.Filter = "BMP File|*.BMP|JPEG File|*.JPG|GIF File|*.GIF|PNG File|*.PNG|ICO File|*.ICO|Image File|*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.EMF;*.WMF;*.TIF;*.PNG;*.ICO|All File|*.*"; OpenFileDialog1.FilterIndex = 6; if (OpenFileDialog1.ShowDialog() == DialogResult.OK) { string strImagePath = OpenFileDialog1.FileName; Image img; img = Image.FromFile(strImagePath); Clipboard.SetDataObject(img); DataFormats.Format df; df = DataFormats.GetFormat(DataFormats.Bitmap); if (richTextBox1.CanPaste(df)) { richTextBox1.Paste(df); } } } |
.
图
.
备注
.
相关链接
相关链接 相关链接
.