如何在为PictureBox选择图像时使用OpenFileDialog? (例如,用户从OpenFileDialog中选择一个图像,它显示在PictureBox中)
任何人都可以帮我编码这个请求吗?
谢谢
J Mahone
答案 0 :(得分:1)
Private Sub btnBrowsePic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowsePic.Click
With OpenFileDialog1
.InitialDirectory = "C:\"
.Filter = "JPEGs|*.jpg|GIFs|*.gif|Bitmaps|*.bmp|AllFiles|*.*"
.FilterIndex = 1
End With
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
With PictureBox1
.Image = Image.FromFile(OpenFileDialog1.FileName)
.SizeMode = PictureBoxSizeMode.CenterImage
.BorderStyle = BorderStyle.Fixed3D
End With
End If
End Sub