private void button1_Click(object sender, EventArgs e) { var openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Image Files | *.JPG"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { var fName = openFileDialog.FileName; Image imge = Image.FromFile(fName); pbImageView.Image = imge; } }
PictureBox的属性【SizeMode】设置为【StretchImage】,所选择的图片会以PictureBox的Size为大小表示。