单击按钮时无法一次查看所有文件类型图像

发布于 2024-12-03 00:48:28 字数 940 浏览 1 评论 0原文

我正在使用下面的代码从系统硬盘上传图像文件......

    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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你穿错了嫁妆 2024-12-10 00:48:28

听起来(根据您的评论)您希望有一个选项可以一次查看所有各种文件类型(即 png、jpg、jpeg 和 gif)。如果是这种情况,请在过滤器中尝试以下操作:

openFileDialog1.Filter = "png files (*.png)|*.png|jpg files (*.jpg)|*.jpg|jpeg files (*.jpeg)|*.jpeg|gif files (*.gif)|*.gif|Image Files(*.png;*.jpg;*.jpeg;*.gif)|*.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:

openFileDialog1.Filter = "png files (*.png)|*.png|jpg files (*.jpg)|*.jpg|jpeg files (*.jpeg)|*.jpeg|gif files (*.gif)|*.gif|Image Files(*.png;*.jpg;*.jpeg;*.gif)|*.png;*.jpg;*.jpeg;*.gif";

The last one combines several in one option - simply separate them by a semi-colon:

FileDialog.Filter Property

北方的巷 2024-12-10 00:48:28

您正在寻找像这样的过滤器值 images|*.png;*.jpg;*.gif 它将显示所有这些类型

You are looking for filter value like this images|*.png;*.jpg;*.gif which will show all these types

倥絔 2024-12-10 00:48:28

您可以添加所有文件 (.)|. 过滤器;

openFileDialog1.Filter = "png files (*.png)|*.png|jpg files (*.jpg)|*.jpg|jpeg files (*.jpeg)|*.jpeg|gif files (*.gif)|*.gif|All files (*.*)|*.*";

You can add All files (.)|. filter;

openFileDialog1.Filter = "png files (*.png)|*.png|jpg files (*.jpg)|*.jpg|jpeg files (*.jpeg)|*.jpeg|gif files (*.gif)|*.gif|All files (*.*)|*.*";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文