码迷,mamicode.com
首页 > 其他好文 > 详细

OpenfileDialog选择照片的简单应用

时间:2016-05-25 09:21:04      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

 

 

            OpenFileDialog openFileDlg = new OpenFileDialog();
            openFileDlg.Title = "选择文件";
            openFileDlg.Multiselect = false;
            openFileDlg.InitialDirectory=Environment.GetFolderPath(Environment.SpecialFolder.Desktop);//设置默认路径为桌面
            openFileDlg.Filter = "(*.jpg,*.png,*.jpeg,*.bmp,*.gif)|*.jgp;*.png;*.jpeg;*.bmp;*.gif|All files(*.*)|*.*"; //设置多文件格式
            if (openFileDlg.ShowDialog() == DialogResult.OK)
            {
                String filePath = openFileDlg.FileName;
                this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                this.pictureBox1.ImageLocation = filePath;//选择照片后在PictureBox中显示
          }

 

OpenfileDialog选择照片的简单应用

标签:

原文地址:http://www.cnblogs.com/AmatVictorialCuram/p/5525757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!