I have a list of products from a database in sql server shown in a datagridview.
My goal is to achieve that through a Picturebox I can assign each product an image, this through a button that opens my files to select an image. Once the image is loaded, the save button will perform its task.
Private Sub btnFoto_Click(sender As Object, e As EventArgs) Handles btnFoto.Click
Dim openfile As New OpenFileDialog()
openfile.ShowDialog()
ruta = openfile.FileName
Try
PictureBox1.Image = Image.FromFile(ruta)
Catch ex As Exception
PictureBox1().Image = Image.FromFile(CurDir() + "\imagen\sin.png")
End Try
End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Try
PictureBox1.Image = Image.FromFile(ruta)
Catch ex As Exception
PictureBox1().Image = Image.FromFile(CurDir() + "\imagen\sin.png")
End Try
End Sub
Private Sub btnGuardar_Click(sender As Object, e As EventArgs) Handles btnGuardar.Click
Try
My.Computer.FileSystem.CopyFile(ruta, CurDir() + "\imagen\" + ".jpg")
Catch ex As Exception
PictureBox1.Image = Image.FromFile(CurDir() + "\imagen\sin.png")
MsgBox("...")
End Try
End Sub
Note: the images are inserted however they are changed in all rows and I don't know how to assign one by one
Thank you.