标签:pdo ring str string focus director show 失败 filter
OpenFileDialog o = new OpenFileDialog();
o.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
o.Title = "请选择图片";
o.Filter = "jpeg|*.jpeg|jpg|*.jpg|png|*.png|gif|*.gif";
if (o.ShowDialog() == DialogResult.OK)
{
picPath = o.FileName;//picPath在前面定义为string
try
{
Image bmp = Image.FromFile(picPath);//picPath为图片路径
Clipboard.SetDataObject(bmp);
DataFormats.Format dataFormat = DataFormats.GetFormat(DataFormats.Bitmap);
if (richText.CanPaste(dataFormat))//图片展示在一个叫richText的richTextBox中
{
richText.Paste(dataFormat);
}
}
catch (Exception exc)
{
MessageBox.Show("图片插入失败。" + exc.Message, "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
richText.Focus();
}
}
标签:pdo ring str string focus director show 失败 filter
原文地址:https://www.cnblogs.com/jakejian/p/9833680.html