单击按钮时无法一次查看所有文件类型图像
我正在使用下面的代码从系统硬盘上传图像文件......
private void btnAddimage_Click(object sender, EventArgs e)
{
openFileDialog1.FileName = @"C:\";
openFileDialog1.Filter = "png files (*.png)|*.png|jpg files (*.jpg)|*.jpg|jpeg files (*.jpeg)|*.jpeg|gif files (*.gif)|*.gif";
openFileDialog1.CheckFileExists = true;
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
Image image1 = Image.FromFile(openFileDialog1.FileName);
pbProductImage.SizeMode = PictureBoxSizeMode.StretchImage;
pbProductImage.Image = image1;
}
}
它工作正常,但是当我单击 btnaddimage 时,文件夹将打开,其中包含具有文件类型扩展名的图像(例如 png、jpeg 和 gif)和 jpeg)..
我的问题是..我无法一次看到所有文件类型的图像..
第一次将使用 png 文件打开一个文件夹,然后我选择了另一种文件类型,例如来自底部提供的组合框的 jpeg对……
当我单击图像按钮一次查看所有文件类型图像(而不是选择 png 文件或 jpeg 文件或 gif 文件……这样)时,我需要做任何更改吗……
会吗?任何人请对此提出任何想法..
非常感谢....
I am using the below code to upload the image files from the system hard disk....
private void btnAddimage_Click(object sender, EventArgs e)
{
openFileDialog1.FileName = @"C:\";
openFileDialog1.Filter = "png files (*.png)|*.png|jpg files (*.jpg)|*.jpg|jpeg files (*.jpeg)|*.jpeg|gif files (*.gif)|*.gif";
openFileDialog1.CheckFileExists = true;
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
Image image1 = Image.FromFile(openFileDialog1.FileName);
pbProductImage.SizeMode = PictureBoxSizeMode.StretchImage;
pbProductImage.Image = image1;
}
}
its working fine but when i click on the btnaddimage the folder will be open with images those have extensions as file type (like png and jpeg and gif and jpeg)..
my problem is ....i am able not able to see the all file type images at a time..
at the first time a folder will be open with png files and then i have select another file type like jpeg from the combobox provided at the bottom right ....
is there any changes i need to do when i click the imagebutton to see the all file type images (rather than selecting the png files or jpeg files or gif files..like that ) at a time...
would any one pls give any idea for this..
many thanks....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来(根据您的评论)您希望有一个选项可以一次查看所有各种文件类型(即 png、jpg、jpeg 和 gif)。如果是这种情况,请在过滤器中尝试以下操作:
最后一个将多个选项合并为一个选项 - 只需用分号分隔它们:
FileDialog.Filter 属性
It sounds like (based on your comment) you want to have an option to see all the various file types at once (i.e., png, jpg, jpeg and gif). If that's the case, try this in your filter:
The last one combines several in one option - simply separate them by a semi-colon:
FileDialog.Filter Property
您正在寻找像这样的过滤器值
images|*.png;*.jpg;*.gif
它将显示所有这些类型You are looking for filter value like this
images|*.png;*.jpg;*.gif
which will show all these types您可以添加所有文件 (.)|. 过滤器;
You can add All files (.)|. filter;