[C#]002_My002App_图片浏览器

002_My002App_图片浏览器

 

Code:

 

private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog p = new OpenFileDialog(); /*初始化一个OpenFileDialog*/
            p.Title = "选择图片"; /*OpenFileDialog的标题*/
            p.InitialDirectory = "c:\\"; /*OpenFileDialog的初始目录*/
            p.Filter = "All files (*.*)|*.*|Image File(*.jpg)(*.png)(*.bmp)|*.jpg;*.png;*.bmp|Text File(*.txt)|*.txt";
            /*定义OpenFileDialog的过滤器*/
            p.FilterIndex = 2; /*定义默认的过滤器*/
            if (p.ShowDialog() == DialogResult.OK)
            {
                picShow.Image = Image.FromFile(p.FileName);
            }
        }

 

 

属性设置:

Anchor: Top, Bottom, Left, Right

SizeMode: Zoom

参考下图:

 

[C#]002_My002App_图片浏览器_第1张图片

你可能感兴趣的:(浏览器,职场,休闲)