开发者

not able to see all file type images at a time when button clicked

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.ShowDia开发者_运维百科log(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....


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


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


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 (*.*)|*.*";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜