richTextBox中插入图片的方法
richTextBox支持图片格式,插入图片的方法如下:
private void button2_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "图片文件|*.jpg|所有文件|*.*";
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
Clipboard.SetDataObject(Image.FromFile(openFileDialog1.FileName),false);
richTextBox1.Paste();
}
}
{
openFileDialog1.Filter = "图片文件|*.jpg|所有文件|*.*";
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
Clipboard.SetDataObject(Image.FromFile(openFileDialog1.FileName),false);
richTextBox1.Paste();
}
}
-----------------------------------------------------------------