Guest User

Guest User

  • Tech Writer
  • 39
  • 11.3k

Show image in picture box clicked from datagridview

Feb 5 2018 3:17 AM
I want to show image in picture box from database clicked in datagridview.
 
Here is my code:
  1. private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)  
  2. {  
  3. if (e.RowIndex >= 0)  
  4. {  
  5. DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];  
  6. txtEmpID.Text = row.Cells[0].Value.ToString();  
  7. txtDeleteAndSearch.Text = row.Cells[0].Value.ToString();  
  8. txtEmpName.Text = row.Cells[1].Value.ToString();  
  9. dateTimePicker1.Text = row.Cells[2].Value.ToString();  
  10. if (row.Cells[3].Value.ToString() == "Male")  
  11. {  
  12. radioMale.Checked = true;  
  13. }  
  14. else  
  15. {  
  16. radioFemale.Checked = true;  
  17. }  
  18. txtEmail.Text = row.Cells[4].Value.ToString();  
  19. txtMSalary.Text = row.Cells[5].Value.ToString();  
  20. txtAddr.Text = row.Cells[6].Value.ToString();  
  21. txtMob.Text = row.Cells[8].Value.ToString();  
  22. pictureBoxEmpPic.Image =row.Cells[9].Value as Image;  
  23. txtPass.Text = row.Cells[10].Value.ToString();  
  24. txtPassConf.Text = txtPass.Text;  
  25. }  
  26. }  
every thing is OK, but image not showing in picturebox,
(pictureBoxEmpPic.Image =row.Cells[9].Value as Image; is not working) 
 
Anybody help me? 

Answers (7)