private void pictureBox1_Click(object sender, EventArgs e) { openFileDialog1.Filter="*.jpg|*.jpg|*.bmp|*.bmp";//设置筛选列表 DialogResult dr=openFileDialog1.ShowDialog();//显示打开文件对话框 if(dr==DialogResult.OK ) { pictureBox1.Image=new Bitmap(openFileDialog1.FileName);//添加将要显示的图像 pictureBox1.SizeMode=PictureBoxSizeMode.StretchImage;//图像被拉伸或收缩以合适大小 } }
时间: 2024-11-13 01:33:28