0
Guys I’m in need of help, already managed to upload images to comics, now I have the following problem: I placed this code to select a datagridview line and fill in the respective fields.
txtIDMovie.Text = dgvMovies.Rows[e.RowIndex].Cells[0].Value.ToString();
txtNameMovie.Text = dgvMovies.Rows[e.RowIndex].Cells[1].Value.ToString();
txtRealizador.Text = dgvMovies.Rows[e.RowIndex].Cells[2].Value.ToString();
txtCatMovies.Text = dgvMovies.Rows[e.RowIndex].Cells[3].Value.ToString();
txtAnoMovie.Text = dgvMovies.Rows[e.RowIndex].Cells[4].Value.ToString();
txtClassIdade.Text = dgvMovies.Rows[e.RowIndex].Cells[5].Value.ToString();
txtClassIMDB.Text = dgvMovies.Rows[e.RowIndex].Cells[6].Value.ToString();
cbFormato.Text = dgvMovies.Rows[e.RowIndex].Cells[7].Value.ToString();
For the image I used:
byte[] bytes = (byte[])dgvMovies.Rows[e.RowIndex].Cells[8].Value;
MemoryStream ms = new MemoryStream(bytes);
pbCapa.Image = Image.FromStream(ms);
However, if you want to edit a field that does not have an image when selecting the line, it is an error. Is there any way to solve?
only test if dgvMovies.Rows[e. Rowindex]. Cells[8]. Value equals null
– Rovann Linhalis