本文介绍了OpenFileDialog中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体和一个图片框。我是要添加图像。这是代码:





OpenFileDialog op = new OpenFileDialog();

op.Filter =图像文件(* .jpg; * .jpeg; * .gif; * .bmp)| * .jpg; * .jpeg; * .gif; * .bmp;

op.ShowDialog() ;



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

{

PictureBox.Image = Image.FromFile(op.FileName);

}

op.Dispose();



但是这儿存在一个问题。当我点击取消它不关闭时,当我第二次点击它关闭时。此外,当我单击图像(Image0001)然后确定文件名变为D:\Images\Image0001。点击第二次工作。

为什么会发生这种情况?

解决方案




I have a windows form and a picturebox in it. I was to add image to it. This is the code:


OpenFileDialog op = new OpenFileDialog();
op.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
op.ShowDialog();

if (op.ShowDialog() == DialogResult.OK)
{
PictureBox.Image = Image.FromFile(op.FileName);
}
op.Dispose();

However there is a problem. When i click cancel its not closing, when i click second time its closing. Also When I click on the image(Image0001)and then OK the filename is becoming D:\Images\Image0001. Clicking second time its working.
Why is this happening?

解决方案




这篇关于OpenFileDialog中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 00:07